CElementTraitsBase Class

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at CElementTraitsBase Class.

This class provides default copy and move methods for a collection class.

template<typename T>  
class CElementTraitsBase

Parameters

T
The type of data to be stored in the collection.

Public Typedefs

NameDescription
CElementTraitsBase::INARGTYPEThe data type to use for adding elements to the collection class object.
CElementTraitsBase::OUTARGTYPEThe data type to use for retrieving elements from the collection class object.

Public Methods

NameDescription
CElementTraitsBase::CopyElementsCall this method to copy elements stored in a collection class object.
CElementTraitsBase::RelocateElementsCall this method to relocate elements stored in a collection class object.

This base class defines methods for copying and relocating elements in a collection class. It is utilized by the classes CDefaultElementTraits, CStringRefElementTraits, and CStringElementTraitsI.

For more information, see ATL Collection Classes.

Header: atlcoll.h

Call this method to copy elements stored in a collection class object.

static void CopyElements(
    T* pDest,
    const T* pSrc,
    size_t nElements);

Parameters

pDest
Pointer to the first element that will receive the copied data.

pSrc
Pointer to the first element to copy.

nElements
The number of elements to copy.

Remarks

The source and destination elements should not overlap.

The data type to use for adding elements to the collection.

typedef const T& INARGTYPE;

The data type to use for retrieving elements from the collection.

typedef T& OUTARGTYPE;

Call this method to relocate elements stored in a collection class object.

static void RelocateElements(
    T* pDest,
    T* pSrc,
    size_t nElements);

Parameters

pDest
Pointer to the first element that will receive the relocated data.

pSrc
Pointer to the first element to relocate.

nElements
The number of elements to relocate.

Remarks

This method calls memmove, which is sufficient for most data types. If the objects being moved contain pointers to their own members, this method will need to be overridden.

Class Overview

Show: