2009-07-17 49 views

回答

7

我见过这种情况在ISO会议中弹出,因为它破坏了一些offsetof()宏实现(LWG 273)。解决办法:&reinterpret_cast<unsigned char&>(variable)

0

& variable.GetInterfacePtr();

+1

这将检索存储在智能指针中的指针地址。不过,我认为问题是关于如何获取智能指针的地址。 – 2009-07-17 11:12:50

3

我定义这个效用函数:

template<typename T> 
T *GetRealAddr(T &t) 
    { return reinterpret_cast<T*>(&reinterpret_cast<unsigned char &>(t)); }