tmp/tmpm8gaeiun/{from.md → to.md}
RENAMED
|
@@ -2,18 +2,17 @@
|
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
namespace std {
|
| 5 |
template <class charT>
|
| 6 |
struct regex_traits {
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
typedef {bitmask_type} char_class_type;
|
| 12 |
|
| 13 |
regex_traits();
|
| 14 |
-
|
| 15 |
charT translate(charT c) const;
|
| 16 |
charT translate_nocase(charT c) const;
|
| 17 |
template <class ForwardIterator>
|
| 18 |
string_type transform(ForwardIterator first, ForwardIterator last) const;
|
| 19 |
template <class ForwardIterator>
|
|
@@ -36,28 +35,28 @@ namespace std {
|
|
| 36 |
The specializations `regex_traits<char>` and `regex_traits<wchar_t>`
|
| 37 |
shall be valid and shall satisfy the requirements for a regular
|
| 38 |
expression traits class ([[re.req]]).
|
| 39 |
|
| 40 |
``` cpp
|
| 41 |
-
|
| 42 |
```
|
| 43 |
|
| 44 |
The type `char_class_type` is used to represent a character
|
| 45 |
classification and is capable of holding an implementation specific set
|
| 46 |
returned by `lookup_classname`.
|
| 47 |
|
| 48 |
``` cpp
|
| 49 |
-
static
|
| 50 |
```
|
| 51 |
|
| 52 |
-
*Returns:* `char_traits<charT>::length(p)
|
| 53 |
|
| 54 |
``` cpp
|
| 55 |
charT translate(charT c) const;
|
| 56 |
```
|
| 57 |
|
| 58 |
-
*Returns:* `
|
| 59 |
|
| 60 |
``` cpp
|
| 61 |
charT translate_nocase(charT c) const;
|
| 62 |
```
|
| 63 |
|
|
@@ -66,11 +65,11 @@ charT translate_nocase(charT c) const;
|
|
| 66 |
``` cpp
|
| 67 |
template <class ForwardIterator>
|
| 68 |
string_type transform(ForwardIterator first, ForwardIterator last) const;
|
| 69 |
```
|
| 70 |
|
| 71 |
-
*Effects:*
|
| 72 |
|
| 73 |
``` cpp
|
| 74 |
string_type str(first, last);
|
| 75 |
return use_facet<collate<charT>>(
|
| 76 |
getloc()).transform(&*str.begin(), &*str.begin() + str.length());
|
|
@@ -79,14 +78,18 @@ return use_facet<collate<charT> >(
|
|
| 79 |
``` cpp
|
| 80 |
template <class ForwardIterator>
|
| 81 |
string_type transform_primary(ForwardIterator first, ForwardIterator last) const;
|
| 82 |
```
|
| 83 |
|
| 84 |
-
*Effects:*
|
| 85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
and the form of the sort key returned by
|
| 87 |
-
`collate_byname<charT>
|
| 88 |
converted into a primary sort key then returns that key, otherwise
|
| 89 |
returns an empty string.
|
| 90 |
|
| 91 |
``` cpp
|
| 92 |
template <class ForwardIterator>
|
|
@@ -104,16 +107,17 @@ template <class ForwardIterator>
|
|
| 104 |
ForwardIterator first, ForwardIterator last, bool icase = false) const;
|
| 105 |
```
|
| 106 |
|
| 107 |
*Returns:* an unspecified value that represents the character
|
| 108 |
classification named by the character sequence designated by the
|
| 109 |
-
iterator range \[`first`, `last`). If the parameter `icase` is true
|
| 110 |
-
the returned mask identifies the character classification without
|
| 111 |
-
to the case of the characters being matched, otherwise it does
|
| 112 |
-
case of the characters being matched.[^1] The value returned
|
| 113 |
-
independent of the case of the characters in the character
|
| 114 |
-
the name is not recognized then returns
|
|
|
|
| 115 |
|
| 116 |
*Remarks:* For `regex_traits<char>`, at least the narrow character names
|
| 117 |
in Table [[tab:re.traits.classnames]] shall be recognized. For
|
| 118 |
`regex_traits<wchar_t>`, at least the wide character names in
|
| 119 |
Table [[tab:re.traits.classnames]] shall be recognized.
|
|
@@ -123,11 +127,11 @@ bool isctype(charT c, char_class_type f) const;
|
|
| 123 |
```
|
| 124 |
|
| 125 |
*Effects:* Determines if the character `c` is a member of the character
|
| 126 |
classification represented by `f`.
|
| 127 |
|
| 128 |
-
*Returns:* Given the following function
|
| 129 |
|
| 130 |
``` cpp
|
| 131 |
// for exposition only
|
| 132 |
template<class C>
|
| 133 |
ctype_base::mask convert(typename regex_traits<C>::char_class_type f);
|
|
@@ -144,60 +148,69 @@ const ctype<charT>& ct = use_facet<ctype<charT>>(getloc());
|
|
| 144 |
if (ct.is(m, c)) {
|
| 145 |
return true;
|
| 146 |
} else if (c == ct.widen('_')) {
|
| 147 |
charT w[1] = { ct.widen('w') };
|
| 148 |
char_class_type x = lookup_classname(w, w+1);
|
| 149 |
-
|
| 150 |
return (f&x) == x;
|
| 151 |
} else {
|
| 152 |
return false;
|
| 153 |
}
|
| 154 |
```
|
| 155 |
|
|
|
|
|
|
|
| 156 |
``` cpp
|
| 157 |
regex_traits<char> t;
|
| 158 |
string d("d");
|
| 159 |
string u("upper");
|
| 160 |
regex_traits<char>::char_class_type f;
|
| 161 |
f = t.lookup_classname(d.begin(), d.end());
|
| 162 |
f |= t.lookup_classname(u.begin(), u.end());
|
| 163 |
ctype_base::mask m = convert<char>(f); // m == ctype_base::digit|ctype_base::upper
|
| 164 |
```
|
| 165 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
``` cpp
|
| 167 |
regex_traits<char> t;
|
| 168 |
string w("w");
|
| 169 |
regex_traits<char>::char_class_type f;
|
| 170 |
f = t.lookup_classname(w.begin(), w.end());
|
| 171 |
t.isctype('A', f); // returns true
|
| 172 |
t.isctype('_', f); // returns true
|
| 173 |
t.isctype(' ', f); // returns false
|
| 174 |
```
|
| 175 |
|
|
|
|
|
|
|
| 176 |
``` cpp
|
| 177 |
int value(charT ch, int radix) const;
|
| 178 |
```
|
| 179 |
|
| 180 |
-
The value of
|
| 181 |
|
| 182 |
-
*Returns:* the value represented by the digit
|
| 183 |
-
the character
|
| 184 |
-
-1.
|
| 185 |
|
| 186 |
``` cpp
|
| 187 |
locale_type imbue(locale_type loc);
|
| 188 |
```
|
| 189 |
|
| 190 |
-
*Effects:* Imbues `this` with a copy of the locale `loc`.
|
| 191 |
-
|
| 192 |
-
|
|
|
|
|
|
|
| 193 |
|
| 194 |
*Returns:* if no locale has been previously imbued then a copy of the
|
| 195 |
global locale in effect at the time of construction of `*this`,
|
| 196 |
otherwise a copy of the last argument passed to `imbue`.
|
| 197 |
|
| 198 |
-
`getloc() == loc`.
|
| 199 |
|
| 200 |
``` cpp
|
| 201 |
locale_type getloc() const;
|
| 202 |
```
|
| 203 |
|
|
|
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
namespace std {
|
| 5 |
template <class charT>
|
| 6 |
struct regex_traits {
|
| 7 |
+
using char_type = charT;
|
| 8 |
+
using string_type = basic_string<char_type>;
|
| 9 |
+
using locale_type = locale;
|
| 10 |
+
using char_class_type = {bitmask_type};
|
|
|
|
| 11 |
|
| 12 |
regex_traits();
|
| 13 |
+
static size_t length(const char_type* p);
|
| 14 |
charT translate(charT c) const;
|
| 15 |
charT translate_nocase(charT c) const;
|
| 16 |
template <class ForwardIterator>
|
| 17 |
string_type transform(ForwardIterator first, ForwardIterator last) const;
|
| 18 |
template <class ForwardIterator>
|
|
|
|
| 35 |
The specializations `regex_traits<char>` and `regex_traits<wchar_t>`
|
| 36 |
shall be valid and shall satisfy the requirements for a regular
|
| 37 |
expression traits class ([[re.req]]).
|
| 38 |
|
| 39 |
``` cpp
|
| 40 |
+
using char_class_type = bitmask_type;
|
| 41 |
```
|
| 42 |
|
| 43 |
The type `char_class_type` is used to represent a character
|
| 44 |
classification and is capable of holding an implementation specific set
|
| 45 |
returned by `lookup_classname`.
|
| 46 |
|
| 47 |
``` cpp
|
| 48 |
+
static size_t length(const char_type* p);
|
| 49 |
```
|
| 50 |
|
| 51 |
+
*Returns:* `char_traits<charT>::length(p)`.
|
| 52 |
|
| 53 |
``` cpp
|
| 54 |
charT translate(charT c) const;
|
| 55 |
```
|
| 56 |
|
| 57 |
+
*Returns:* `c`.
|
| 58 |
|
| 59 |
``` cpp
|
| 60 |
charT translate_nocase(charT c) const;
|
| 61 |
```
|
| 62 |
|
|
|
|
| 65 |
``` cpp
|
| 66 |
template <class ForwardIterator>
|
| 67 |
string_type transform(ForwardIterator first, ForwardIterator last) const;
|
| 68 |
```
|
| 69 |
|
| 70 |
+
*Effects:* As if by:
|
| 71 |
|
| 72 |
``` cpp
|
| 73 |
string_type str(first, last);
|
| 74 |
return use_facet<collate<charT>>(
|
| 75 |
getloc()).transform(&*str.begin(), &*str.begin() + str.length());
|
|
|
|
| 78 |
``` cpp
|
| 79 |
template <class ForwardIterator>
|
| 80 |
string_type transform_primary(ForwardIterator first, ForwardIterator last) const;
|
| 81 |
```
|
| 82 |
|
| 83 |
+
*Effects:* If
|
| 84 |
+
|
| 85 |
+
``` cpp
|
| 86 |
+
typeid(use_facet<collate<charT>>) == typeid(collate_byname<charT>)
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
and the form of the sort key returned by
|
| 90 |
+
`collate_byname<charT>::transform(first, last)` is known and can be
|
| 91 |
converted into a primary sort key then returns that key, otherwise
|
| 92 |
returns an empty string.
|
| 93 |
|
| 94 |
``` cpp
|
| 95 |
template <class ForwardIterator>
|
|
|
|
| 107 |
ForwardIterator first, ForwardIterator last, bool icase = false) const;
|
| 108 |
```
|
| 109 |
|
| 110 |
*Returns:* an unspecified value that represents the character
|
| 111 |
classification named by the character sequence designated by the
|
| 112 |
+
iterator range \[`first`, `last`). If the parameter `icase` is `true`
|
| 113 |
+
then the returned mask identifies the character classification without
|
| 114 |
+
regard to the case of the characters being matched, otherwise it does
|
| 115 |
+
honor the case of the characters being matched.[^1] The value returned
|
| 116 |
+
shall be independent of the case of the characters in the character
|
| 117 |
+
sequence. If the name is not recognized then returns
|
| 118 |
+
`char_class_type()`.
|
| 119 |
|
| 120 |
*Remarks:* For `regex_traits<char>`, at least the narrow character names
|
| 121 |
in Table [[tab:re.traits.classnames]] shall be recognized. For
|
| 122 |
`regex_traits<wchar_t>`, at least the wide character names in
|
| 123 |
Table [[tab:re.traits.classnames]] shall be recognized.
|
|
|
|
| 127 |
```
|
| 128 |
|
| 129 |
*Effects:* Determines if the character `c` is a member of the character
|
| 130 |
classification represented by `f`.
|
| 131 |
|
| 132 |
+
*Returns:* Given the following function declaration:
|
| 133 |
|
| 134 |
``` cpp
|
| 135 |
// for exposition only
|
| 136 |
template<class C>
|
| 137 |
ctype_base::mask convert(typename regex_traits<C>::char_class_type f);
|
|
|
|
| 148 |
if (ct.is(m, c)) {
|
| 149 |
return true;
|
| 150 |
} else if (c == ct.widen('_')) {
|
| 151 |
charT w[1] = { ct.widen('w') };
|
| 152 |
char_class_type x = lookup_classname(w, w+1);
|
|
|
|
| 153 |
return (f&x) == x;
|
| 154 |
} else {
|
| 155 |
return false;
|
| 156 |
}
|
| 157 |
```
|
| 158 |
|
| 159 |
+
[*Example 1*:
|
| 160 |
+
|
| 161 |
``` cpp
|
| 162 |
regex_traits<char> t;
|
| 163 |
string d("d");
|
| 164 |
string u("upper");
|
| 165 |
regex_traits<char>::char_class_type f;
|
| 166 |
f = t.lookup_classname(d.begin(), d.end());
|
| 167 |
f |= t.lookup_classname(u.begin(), u.end());
|
| 168 |
ctype_base::mask m = convert<char>(f); // m == ctype_base::digit|ctype_base::upper
|
| 169 |
```
|
| 170 |
|
| 171 |
+
— *end example*]
|
| 172 |
+
|
| 173 |
+
[*Example 2*:
|
| 174 |
+
|
| 175 |
``` cpp
|
| 176 |
regex_traits<char> t;
|
| 177 |
string w("w");
|
| 178 |
regex_traits<char>::char_class_type f;
|
| 179 |
f = t.lookup_classname(w.begin(), w.end());
|
| 180 |
t.isctype('A', f); // returns true
|
| 181 |
t.isctype('_', f); // returns true
|
| 182 |
t.isctype(' ', f); // returns false
|
| 183 |
```
|
| 184 |
|
| 185 |
+
— *end example*]
|
| 186 |
+
|
| 187 |
``` cpp
|
| 188 |
int value(charT ch, int radix) const;
|
| 189 |
```
|
| 190 |
|
| 191 |
+
*Requires:* The value of `radix` shall be 8, 10, or 16.
|
| 192 |
|
| 193 |
+
*Returns:* the value represented by the digit `ch` in base `radix` if
|
| 194 |
+
the character `ch` is a valid digit in base `radix`; otherwise returns
|
| 195 |
+
`-1`.
|
| 196 |
|
| 197 |
``` cpp
|
| 198 |
locale_type imbue(locale_type loc);
|
| 199 |
```
|
| 200 |
|
| 201 |
+
*Effects:* Imbues `this` with a copy of the locale `loc`.
|
| 202 |
+
|
| 203 |
+
[*Note 1*: Calling `imbue` with a different locale than the one
|
| 204 |
+
currently in use invalidates all cached data held by
|
| 205 |
+
`*this`. — *end note*]
|
| 206 |
|
| 207 |
*Returns:* if no locale has been previously imbued then a copy of the
|
| 208 |
global locale in effect at the time of construction of `*this`,
|
| 209 |
otherwise a copy of the last argument passed to `imbue`.
|
| 210 |
|
| 211 |
+
*Postconditions:* `getloc() == loc`.
|
| 212 |
|
| 213 |
``` cpp
|
| 214 |
locale_type getloc() const;
|
| 215 |
```
|
| 216 |
|