Chapter 3. ATL Smart Types

VARIANTs, SAFEARRAYs, and Interface Pointers

COM has a number of data types beyond the numeric types available in the C and C++ languages. Three such data types are the VARIANT data type, interface pointers, and the SAFEARRAY data type. ATL provides useful classes that encapsulate each of these data types and their special idiosyncrasies.

The CComVariant class is a smart VARIANT class. The class implements the special initialization, copy, and destruction semantics of the COM VARIANT data type. CComVariant instances can be used in most, but not all, of the places you would use a VARIANT.

The CComPtr, CComQIPtr, and CComGITPtr classes are smart pointer classes. Smart pointer classes are definitions of objects that “act” ...

Get ATL Internals: Working with ATL 8, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.