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.

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

Parameters

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

Public Methods

NameDescription
CStringRefElementTraits::CompareElementsCall this static function to compare two string elements for equality.
CStringRefElementTraits::CompareElementsOrderedCall this static function to compare two string elements.
CStringRefElementTraits::HashCall this static function to calculate a hash value for the given string element.

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.

CElementTraitsBase

CStringRefElementTraits

Header: atlcoll.h

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.

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.

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.

CElementTraitsBase Class
Class Overview

Show: