c++ - How to convert integers to pointers and vice versa -


suppose there std::multiset<some_data_type> s, how can save address of thisstd::multiset in integer , use integer assign other pointers location? mean possible this:

std::multiset<int> myset;  //insert data in myset int = address_of(myset); std::multiset<int>* otherset = location(a); 

this c++11's intptr_t type gives <cstdint>, if system supports (which standard not mandate).

if it's available, it's guaranteed large enough hold pointer value (unlike int), , defined such converting , intptr_t , the same pointer type safe. you'll need reinterpret_cast each conversion.

you don't want this if can avoid it. use original pointer type possible. types good!


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -