64 lines
2.1 KiB
Markdown
64 lines
2.1 KiB
Markdown
[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 "26 Algorithms 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.2 Sorting"), [[vector]](vector "23.3.13 Class template vector")):
|
||
|
||
std::sort(v.begin(), v.end(), loc); â *end example*]
|