Skip to content

Latest commit

 

History

History
101 lines (64 loc) · 3.49 KB

ccomenumonstl-class.md

File metadata and controls

101 lines (64 loc) · 3.49 KB
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: CComEnumOnSTL Class
CComEnumOnSTL Class
11/04/2016
CComEnumOnSTL
atlcom/ATL::CComEnumOnSTL
CComEnumOnSTL class
befe1a44-7a00-4f28-9a2e-cc0fa526643c

CComEnumOnSTL Class

This class defines a COM enumerator object based on a C++ Standard Library collection.

Syntax

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>

Parameters

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.

Remarks

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.

To use this class with ICollectionOnSTLImpl:

  • typedef a specialization of this class.

  • Use the typedef as the final template argument in a specialization of ICollectionOnSTLImpl.

See ATL Collections and Enumerators for an example.

To use this class independently of ICollectionOnSTLImpl:

  • typedef a specialization of this class.

  • Use the typedef as the template argument in a specialization of CComObject.

  • Create an instance of the CComObject specialization.

  • Initialize the enumerator object by calling IEnumOnSTLImpl::Init.

  • Return the enumerator interface to the client.

Inheritance Hierarchy

CComObjectRootBase

Base

CComObjectRootEx

IEnumOnSTLImpl

CComEnumOnSTL

Requirements

Header: atlcom.h

Example

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 CComVariants by means of the IEnumVariant interface. The CVariantCollection class simply specializes CreateSTLEnumerator to work with enumerator objects of this type.

See also

IEnumOnSTLImpl
ATLCollections Sample: Demonstrates ICollectionOnSTLImpl, CComEnumOnSTL, and Custom Copy Policy Classes
Class Overview
CComObjectRootEx Class
CComObjectThreadModel
IEnumOnSTLImpl Class