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

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -