Export (0) Print
Expand All

CStringT::operator <

Determines if the string on the left side of the operator is less than to the string on the right side.

CThisString& operator<(
   const CStringT& str1,
   const CStringT& str2
) throw();
CThisString& operator<(
   const CStringT& str1
   PCXSTR psz2
) throw();
CThisString& operator<(
   PCXSTR psz1
   const CStringT& str2
) throw();

Parameters

str1
A CStringT for comparison.
str2
A CStringT for comparison.
psz1
A pointer to a null-terminated string for comparison.
psz2
A pointer to a null-terminated string for comparison.

Remarks

A lexicographical comparison between strings, character by character until:

  • It finds two corresponding characters unequal, and the result of their comparison is taken as the result of the comparison between the strings.
  • It finds no inequalities, but one string has more characters than the other, and the shorter string is considered less than the longer string.
  • It finds no inequalities and finds that the strings have the same number of characters, and so the strings are equal.

Example

The following example demonstrates the use of CStringT::operator <.

//typedef CStringT< TCHAR, StrTraitATL< TCHAR > > CAtlString;
CAtlString s1("cat"), s2("cats"), s3("dogs");

_ASSERT(s1 < "dog");
_ASSERT(s1 < "cats");
_ASSERT(s2 < "cats and dogs");
_ASSERT(s2 < s3);

See Also

CStringT Overview | Class Members

Show:
© 2015 Microsoft