This template is used to wrap classes that redefine the address-of operator to return something other than the address of the object.
CAdapt is a simple template used to wrap classes that redefine the address-of operator (operator &) to return something other than the address of the object. Examples of such classes include ATL's CComBSTR, CComPtr, and CComQIPtr classes, and the compiler COM support class, _com_ptr_t. These classes all redefine the address-of operator to return the address of one of their data members (a BSTR in the case of CComBSTR, and an interface pointer in the case of the other classes).
CAdapt's primary role is to hide the address-of operator defined by class T, yet still retain the characteristics of the adapted class. CAdapt fulfils this role by holding a public member, m_T, of type T, and by defining conversion operators, comparison operators, and a copy constructor to allow specializations of CAdapt to be treated as if they are objects of type T.
The adapter class CAdapt is useful because many container classes (such as the STL container classes) expect to be able to obtain the addresses of their contained objects using the address-of operator. The redefinition of the address-of operator can confound this requirement, typically causing compilation errors and preventing the use of the unadapted type with that container. CAdapt provides a way around those problems.
Typically, you will use CAdapt when you want to store CComBSTR, CComPtr, CComQIPtr, or _com_ptr_t objects in an STL container such as a list. You can't store objects of these types like this:
Instead, you should store adapter objects like this: