_com_ptr_重载运算符&()有副作用。如果我有一个变量:如果一个运算符为C++类重载,我该如何使用默认运算符呢?
_com_ptr_t<Interface> variable;
我怎么能检索其地址(_com_ptr_t <接口> *指针),而不调用重载运算符和引发副作用?
_com_ptr_重载运算符&()有副作用。如果我有一个变量:如果一个运算符为C++类重载,我该如何使用默认运算符呢?
_com_ptr_t<Interface> variable;
我怎么能检索其地址(_com_ptr_t <接口> *指针),而不调用重载运算符和引发副作用?
我见过这种情况在ISO会议中弹出,因为它破坏了一些offsetof()宏实现(LWG 273)。解决办法:&reinterpret_cast<unsigned char&>(variable)
& variable.GetInterfacePtr();
这将检索存储在智能指针中的指针地址。不过,我认为问题是关于如何获取智能指针的地址。 – 2009-07-17 11:12:50
我定义这个效用函数:
template<typename T>
T *GetRealAddr(T &t)
{ return reinterpret_cast<T*>(&reinterpret_cast<unsigned char &>(t)); }
你想的`_com_ptr_t *`或`的接口*`? –
MSalters
2009-07-17 11:11:08
我想要一个_com_ptr_t <> *。 – sharptooth 2009-07-17 11:11:55