次の方法で共有


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.

Syntax

template<typename T>  
class CDefaultCompareTraits

Parameters

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

Members

Public Methods

Name Description
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.

Remarks

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.

Requirements

Header: atlcoll.h

CDefaultCompareTraits::CompareElements

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.

CDefaultCompareTraits::CompareElementsOrdered

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:

Condition Return value
element1 < element2 <0
element1 == element2 0
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.

See Also

Class Overview