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
Post a Comment