The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.



Called directly by CList::Find and indirectly by CMap::Lookup and CMap::operator [].

      template<class TYPE, class ARG_TYPE> 
BOOL AFXAPI CompareElements(
   const TYPE* pElement1,
   const ARG_TYPE* pElement2 


The type of the first element to be compared.


Pointer to the first element to be compared.


The type of the second element to be compared.


Pointer to the second element to be compared.

Nonzero if the object pointed to by pElement1 is equal to the object pointed to by pElement2; otherwise 0.

The CMap calls use the CMap template parameters KEY and ARG_KEY.

The default implementation returns the result of the comparison of *pElement1 and *pElement2. Override this function so that it compares the elements in a way that is appropriate for your application.

The C++ language defines the comparison operator (==) for simple types (char, int, float, and so on) but does not define a comparison operator for classes and structures. If you want to use CompareElements or to instantiate one of the collection classes that uses it, you must either define the comparison operator or overload CompareElements with a version that returns appropriate values.


Header: afxtempl.h