tmp/tmpi9jbli_w/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
##### General <a id="locale.collate.general">[[locale.collate.general]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
namespace std {
|
| 5 |
+
template<class charT>
|
| 6 |
+
class collate : public locale::facet {
|
| 7 |
+
public:
|
| 8 |
+
using char_type = charT;
|
| 9 |
+
using string_type = basic_string<charT>;
|
| 10 |
+
|
| 11 |
+
explicit collate(size_t refs = 0);
|
| 12 |
+
|
| 13 |
+
int compare(const charT* low1, const charT* high1,
|
| 14 |
+
const charT* low2, const charT* high2) const;
|
| 15 |
+
string_type transform(const charT* low, const charT* high) const;
|
| 16 |
+
long hash(const charT* low, const charT* high) const;
|
| 17 |
+
|
| 18 |
+
static locale::id id;
|
| 19 |
+
|
| 20 |
+
protected:
|
| 21 |
+
~collate();
|
| 22 |
+
virtual int do_compare(const charT* low1, const charT* high1,
|
| 23 |
+
const charT* low2, const charT* high2) const;
|
| 24 |
+
virtual string_type do_transform(const charT* low, const charT* high) const;
|
| 25 |
+
virtual long do_hash (const charT* low, const charT* high) const;
|
| 26 |
+
};
|
| 27 |
+
}
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
The class `collate<charT>` provides features for use in the collation
|
| 31 |
+
(comparison) and hashing of strings. A locale member function template,
|
| 32 |
+
`operator()`, uses the collate facet to allow a locale to act directly
|
| 33 |
+
as the predicate argument for standard algorithms [[algorithms]] and
|
| 34 |
+
containers operating on strings. The specializations required in
|
| 35 |
+
[[locale.category.facets]] [[locale.category]], namely `collate<char>`
|
| 36 |
+
and `collate<wchar_t>`, apply lexicographical ordering
|
| 37 |
+
[[alg.lex.comparison]].
|
| 38 |
+
|
| 39 |
+
Each function compares a string of characters `*p` in the range \[`low`,
|
| 40 |
+
`high`).
|
| 41 |
+
|