description | title | ms.date | f1_keywords | helpviewer_keywords | ms.assetid | |||
---|---|---|---|---|---|---|---|---|
Learn more about: CComEnumOnSTL Class |
CComEnumOnSTL Class |
11/04/2016 |
|
|
befe1a44-7a00-4f28-9a2e-cc0fa526643c |
This class defines a COM enumerator object based on a C++ Standard Library collection.
template <class Base,
const IID* piid, class T, class Copy, class CollType, class ThreadModel = CComObjectThreadModel>
class ATL_NO_VTABLE CComEnumOnSTL : public IEnumOnSTLImpl<Base, piid,
T,
Copy,
CollType>,
public CComObjectRootEx<ThreadModel>
Base
A COM enumerator. See IEnumString for an example.
piid
A pointer to the interface ID of the enumerator interface.
T
The type of item exposed by the enumerator interface.
Copy
A copy policy class.
CollType
A C++ Standard Library container class.
CComEnumOnSTL
defines a COM enumerator object based on a C++ Standard Library collection. This class can be used on its own or in conjunction with ICollectionOnSTLImpl. Typical steps for using this class are outlined below. For more information, see ATL Collections and Enumerators.
-
typedef
a specialization of this class. -
Use the
typedef
as the final template argument in a specialization ofICollectionOnSTLImpl
.
See ATL Collections and Enumerators for an example.
-
typedef
a specialization of this class. -
Use the
typedef
as the template argument in a specialization ofCComObject
. -
Create an instance of the
CComObject
specialization. -
Initialize the enumerator object by calling IEnumOnSTLImpl::Init.
-
Return the enumerator interface to the client.
CComObjectRootBase
Base
CComEnumOnSTL
Header: atlcom.h
The code shown below provides a generic function to handle the creation and initialization of an enumerator object:
[!code-cppNVC_ATL_COM#34]
This function template can be used to implement the _NewEnum
property of a collection interface as shown below:
[!code-cppNVC_ATL_COM#35]
This code creates a typedef
for CComEnumOnSTL
that exposes a vector of CComVariant
s by means of the IEnumVariant
interface. The CVariantCollection
class simply specializes CreateSTLEnumerator
to work with enumerator objects of this type.
IEnumOnSTLImpl
ATLCollections Sample: Demonstrates ICollectionOnSTLImpl, CComEnumOnSTL, and Custom Copy Policy Classes
Class Overview
CComObjectRootEx Class
CComObjectThreadModel
IEnumOnSTLImpl Class