If an operator is overloaded for a C++ class how could I use a default operator instead?

前端 未结 3 1077
一生所求
一生所求 2020-12-10 18:46

_com_ptr_ has an overloaded operator&() with a side effect. If I have a variable:

_com_ptr_t variable;

How could I ret

相关标签:
3条回答
  • 2020-12-10 19:31

    I've seen this case pop up in an ISO meeting as it broke some offsetof() macro implementations (LWG 273). The solution: &reinterpret_cast<unsigned char&>(variable)

    0 讨论(0)
  • 2020-12-10 19:32

    &variable.GetInterfacePtr();

    0 讨论(0)
  • 2020-12-10 19:36

    I define this utility function:

    template<typename T>
    T *GetRealAddr(T &t)
        { return reinterpret_cast<T*>(&reinterpret_cast<unsigned char &>(t)); }
    
    0 讨论(0)
提交回复
热议问题