std::collate_byname(3)
β¨ std::collate_byname π
okay so welcome to the <locale> corner of the C++ Standard Libary manual, bestie β this page is std::collate_byname(3), and it's literally all about locale-flavored string collation. no cap. π¦
πΈ NAME πΈ
std::collate_byname β yes, that's the whole name, she's self-titled and iconic π
π Synopsis π
Defined in header <locale>:
template< class CharT >
class collate_byname : public std::collate<CharT>;
std::collate_byname is a std::collate facet which encapsulates locale-specific collation (comparison) and hashing of strings. Just like std::collate, it can be imbued in std::regex and applied, by means of std::locale::operator(), directly to all standard algorithms that expect a string comparison predicate. periodt. π
π Specializations π
The standard library is guaranteed to provide the following specializations:
Defined in header <locale>:
std::collate_byname<char> locale-specific collation of multibyte strings
std::collate_byname<wchar_t> locale-specific collation of wide strings
π Member functions π
- constructor β constructs a new
collate_bynamefacet (public member function) - destructor β destroys a
collate_bynamefacet (protected member function)
π οΈ std::collate_byname::collate_byname π οΈ
explicit collate_byname( const char* name, std::size_t refs = 0 );
explicit collate_byname( const std::string& name, std::size_t refs = 0 );
theconst std::string&overload is(since C++11)β¨
Constructs a new std::collate_byname facet for a locale with name.
refs is used for resource management: if refs == 0, the implementation destroys the facet when the last std::locale object holding it is destroyed. Otherwise, the object is not destroyed. resource-management queen behavior, honestly π
π Parameters π
- name β the name of the locale
- refs β the number of references that link to the facet
π§ std::collate_byname::~collate_byname π§
protected:
~collate_byname();
Destroys the facet. clean, quiet, protected. she said goodbye on her own terms π
π Inherited from std::collate π
π Member types π
char_typeβCharTstring_typeβstd::basic_string<CharT>
β Member functions β
compareβ invokesdo_compare(public member function ofstd::collate<CharT>)transformβ invokesdo_transform(public member function ofstd::collate<CharT>)hashβ invokesdo_hash(public member function ofstd::collate<CharT>)
π₯ Protected member functions π₯
do_compareβ compares two strings using this facet's collation rules[virtual](virtual protected member function ofstd::collate<CharT>)do_transformβ transforms a string so that collation can be replaced by comparison[virtual](virtual protected member function ofstd::collate<CharT>)do_hashβ generates an integer hash value using this facet's collation rules[virtual](virtual protected member function ofstd::collate<CharT>)
π Notes π
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". likeβ¦ the way collation has lore is so real π
π«Ά Example π«Ά
This section is incomplete.
Reason: no example.
not me wanting an example too π but that's literally what the page says.
π¦ See also π¦
collateβ defines lexicographical comparison and hashing of strings (class template)strcollβ compares two strings in accordance to the current locale (function)wcscollβ compares two wide strings in accordance to the current locale (function)operator()β lexicographically compares two strings using this locale'scollatefacet (public member function ofstd::locale)
πΈ Category πΈ
Todo no example
mwah π this cute little manual moment came from http://cppreference.com, version/date 2024.06.10, and the page is std::collate_byname(3) β periodt. π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms