Search code examples
c++comgeneric-programming

Get the address of an object that has overloaded operator&


operator& for CComPtr is overloaded, which makes my generically written code crash.

I am wondering if there is any way to force a variable into returning the address of it's object?


Solution

  • The solution is hideous:

    reinterpret_cast<CComPtr*>(&reinterpret_cast<char&>(ptr))