CDefaultCompareTraits 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 CDefaultCompareTraits Class.

This class provides default element comparison functions.

template<typename T>  
class CDefaultCompareTraits

Parameters

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

Public Methods

NameDescription
CDefaultCompareTraits::CompareElements(Static) Call this function to compare two elements for equality.
CDefaultCompareTraits::CompareElementsOrdered(Static) Call this function to determine the greater and lesser element.

This class contains two static functions for comparing elements stored in a collection class object. This class is utilized by the CDefaultElementTraits Class.

For more information, see ATL Collection Classes.

Header: atlcoll.h

Call this function to compare two elements for equality.

static bool CompareElements(const T& element1, const T& element2);

Parameters

element1
The first element.

element2
The second element.

Return Value

Returns true if the elements are equal, false otherwise.

Remarks

The default implementation of this function is the equality ( ==) operator. For objects other than simple data types, this function may need to be overridden.

Call this function to determine the greater and lesser element.

static int CompareElementsOrdered(const T& element1, const T& element2);

Parameters

element1
The first element.

element2
The second element.

Return Value

Returns an integer based on the following table:

ConditionReturn value
element1 < element2<0
element1 == element20
element1 > element2>0

Remarks

The default implementation of this function uses the ==, <, and > operators. For objects other than simple data types, this function may need to be overridden.

Class Overview

Show: