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

This class provides static functions related to strings stored in collection class objects. The string objects are dealt with as references.

Syntax

template <typename T>  
class CStringRefElementTraits : public CElementTraitsBase<T>

Parameters

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

Members

Public Methods

Name Description
CStringRefElementTraits::CompareElements Call this static function to compare two string elements for equality.
CStringRefElementTraits::CompareElementsOrdered Call this static function to compare two string elements.
CStringRefElementTraits::Hash Call this static function to calculate a hash value for the given string element.

Remarks

This class provides static functions for comparing strings and for creating a hash value. These functions are useful when using a collection class to store string-based data. Unlike CStringElementTraits and CStringElementTraitsI, CStringRefElementTraits causes the CString arguments to be passed as const CString& references.

For more information, see ATL Collection Classes.

Inheritance Hierarchy

CElementTraitsBase

CStringRefElementTraits

Requirements

Header: atlcoll.h

CStringRefElementTraits::CompareElements

Call this static function to compare two string elements for equality.

static bool CompareElements(INARGTYPE element1, INARGTYPE element2) throw();

Parameters

element1
The first string element.

element2
The second string element.

Return Value

Returns true if the elements are equal, false otherwise.

CStringRefElementTraits::CompareElementsOrdered

Call this static function to compare two string elements.

static int CompareElementsOrdered(INARGTYPE str1, INARGTYPE str2) throw();

Parameters

str1
The first string element.

str2
The second string element.

Return Value

Zero if the strings are identical, < 0 if str1 is less than str2, or > 0 if str1 is greater than str2. The CStringT::Compare method is used to perform the comparisons.

CStringRefElementTraits::Hash

Call this static function to calculate a hash value for the given string element.

static ULONG Hash(INARGTYPE str) throw();

Parameters

str
The string element.

Return Value

Returns a hash value, calculated using the string's contents.

See Also

CElementTraitsBase Class
Class Overview