Files
cppdraft_translate/cppdraft/locale/operators.md
2025-10-25 03:02:53 +03:00

64 lines
2.1 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[locale.operators]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.operators)
### 28.3.3 Locales [[locales]](locales#locale.operators)
#### 28.3.3.1 Class locale [[locale]](locale#operators)
#### 28.3.3.1.5 Operators [locale.operators]
[🔗](#lib:locale,operator==)
`bool operator==(const locale& other) const;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1070)
*Returns*: true if
both arguments are the same locale, or
one is a copy of the other, or
each has a name and the names are identical;false otherwise[.](#1.sentence-1)
[🔗](#lib:locale,operator())
`template<class charT, class traits, class Allocator>
bool operator()(const basic_string<charT, traits, Allocator>& s1,
const basic_string<charT, traits, Allocator>& s2) const;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1087)
*Effects*: Compares two strings according to the std::collate<charT> facet[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1091)
*Returns*: use_facet<std::collate<charT>>(*this).compare(s1.data(), s1.data() + s1.size(),
s2.data(), s2.data() + s2.size()) < 0
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1098)
*Remarks*: This member operator template (and therefore locale itself)
meets the requirements for
a comparator predicate template argument ([[algorithms]](algorithms "26Algorithms library")) applied to strings[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1104)
[*Example [1](#example-1)*:
A vector of strings v can be collated according to collation rules in locale loc simply by ([[alg.sort]](alg.sort "26.8.2Sorting"), [[vector]](vector "23.3.13Class template vector")):
std::sort(v.begin(), v.end(), loc); — *end example*]