c++ - Saving 'this' address into a variable -


will save address of pointing to:

size_t this_address = size_t(this); 

is portable? need save address of pointing to. suggestion on if there correct way go this. note, optimization purposes.

void * more portable and, in opinion, more correct way store pointer address:

void *this_address = this; 

this said, why need portable? not type-safe @ all, should use pointer correct (base)-type or, when applicable, smart pointer of (base)-type.


Comments

Popular posts from this blog

vb.net - Alternative to the T-SQL AS keyword -

php - MySQLi binding parameters in a prepared statement doesn't work unless inserted after "WHERE" -

ios - CFRelease causing crash in iPad application -