std::collate<CharT>::compare,std::collate<CharT>::do_compare (3) - Linux Manuals
std::collate<CharT>::compare,std::collate<CharT>::do_compare: std::collate<CharT>::compare,std::collate<CharT>::do_compare
NAME
std::collate<CharT>::compare,std::collate<CharT>::do_compare - std::collate<CharT>::compare,std::collate<CharT>::do_compare
Synopsis
Defined in header <locale>
public:
int compare( const CharT* low1, const CharT* high1, (1)
const CharT* low2, const CharT* high2 ) const;
protected:
virtual int do_compare( const CharT* low1, const CharT* high1, (2)
const CharT* low2, const CharT* high2 ) const;
1) Public member function, calls the protected virtual member function do_compare of the most derived class.
2) Compares the character sequence [low1, high1) to the character sequence [low2, high2), using this locale's collation rules, and returns 1 if the first string follows the second, -1 if the first string precedes the second, zero if the two strings are equivalent.
Parameters
low1 - pointer to the first character of the first string
high1 - one past the end pointer for the first string
low2 - pointer to the first character of the second string
high2 - one past the end pointer for the second string
Return value
1 if the first string is greater than the second (that is, follows the second in the collation order), -1 if the first string is less than the second (precedes the second in the collation order), zero if the two strings are equivalent.
Notes
When three-way comparison is not required (such as when providing a Compare argument to standard algorithms such as std::sort), std::locale::operator() may be more appropriate.
Collation order is the dictionary order: the position of the letter in the national alphabet (its equivalence class) has higher priority than its case or variant. Within an equivalence class, lowercase characters collate before their uppercase equivalents and locale-specific order may apply to the characters with diacritics. In some locales, groups of characters compare as single collation units. For example, "ch" in Czech follows "h" and precedes "i", and "dzs" in Hungarian follows "dz" and precedes "g".
Example
// Run this code
Output:
See also
strcoll (function)
wcscoll (function)
operator() (public member function of std::locale)