• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1[/
2 / Copyright (c) 2008 Eric Niebler
3 /
4 / Distributed under the Boost Software License, Version 1.0. (See accompanying
5 / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 /]
7
8[section Concepts]
9
10[h2 CharT requirements]
11If type `BidiIterT` is used as a template argument to _basic_regex_, then `CharT` is
12`iterator_traits<BidiIterT>::value_type`. Type `CharT` must have a trivial default
13constructor, copy constructor, assignment operator, and destructor.  In addition
14the following requirements must be met for objects; `c` of type `CharT`, `c1` and `c2` of
15type `CharT const`, and `i` of type `int`:
16
17[table CharT Requirements
18    [
19        [[*Expression]]
20        [[*Return type]]
21        [[*Assertion / Note / Pre- / Post-condition]]
22    ]
23    [
24        [`CharT c`]
25        [`CharT`]
26        [Default constructor (must be trivial).]
27    ]
28    [
29        [`CharT c(c1)`]
30        [`CharT`]
31        [Copy constructor (must be trivial).]
32    ]
33    [
34        [`c1 = c2`]
35        [`CharT`]
36        [Assignment operator (must be trivial).]
37    ]
38    [
39        [`c1 == c2`]
40        [`bool`]
41        [`true` if `c1` has the same value as `c2`.]
42    ]
43    [
44        [`c1 != c2`]
45        [`bool`]
46        [`true` if `c1` and `c2` are not equal.]
47    ]
48    [
49        [`c1 < c2`]
50        [`bool`]
51        [`true` if the value of `c1` is less than `c2`.]
52    ]
53    [
54        [`c1 > c2`]
55        [`bool`]
56        [`true` if the value of `c1` is greater than `c2`.]
57    ]
58    [
59        [`c1 <= c2`]
60        [`bool`]
61        [`true` if `c1` is less than or equal to `c2`.]
62    ]
63    [
64        [`c1 >= c2`]
65        [`bool`]
66        [`true` if `c1` is greater than or equal to `c2`.]
67    ]
68    [
69        [`intmax_t i = c1`]
70        [`int`]
71        [
72            `CharT` must be convertible to an integral type.
73        ]
74    ]
75    [
76        [`CharT c(i);`]
77        [`CharT`]
78        [`CharT` must be constructable from an integral type.]
79    ]
80]
81
82[h2 Traits Requirements]
83In the following table `X` denotes a traits class defining types and functions
84for the character container type `CharT`; `u` is an object of type `X`; `v` is an
85object of type `const X`; `p` is a value of type `const CharT*`; `I1` and `I2` are
86`Input Iterators`; `c` is a value of type `const CharT`; `s` is an object of type
87`X::string_type`; `cs` is an object of type `const X::string_type`; `b` is a value of
88type `bool`; `i` is a value of type `int`; `F1` and `F2` are values of type `const CharT*`;
89`loc` is an object of type `X::locale_type`; and `ch` is an object of `const char`.
90
91[table Traits Requirements
92    [
93        [
94            [*Expression]
95        ]
96        [
97            [*Return type]
98        ]
99        [
100            [*Assertion / Note\n
101                Pre / Post condition]
102        ]
103    ]
104    [
105        [
106            `X::char_type`
107        ]
108        [
109            `CharT`
110        ]
111        [
112            The character container type used in the implementation of class template _basic_regex_.
113        ]
114    ]
115    [
116        [
117            `X::string_type`
118        ]
119        [
120            `std::basic_string<CharT>` or `std::vector<CharT>`
121        ]
122        [
123
124        ]
125    ]
126    [
127        [
128            `X::locale_type`
129        ]
130        [
131            ['Implementation defined]
132        ]
133        [
134            A copy constructible type that represents the locale used by the traits class.
135        ]
136    ]
137    [
138        [
139            `X::char_class_type`
140        ]
141        [
142            ['Implementation defined]
143        ]
144        [
145            A bitmask type representing a particular character classification. Multiple
146                values of this type can be bitwise-or'ed together to obtain a new valid value.
147        ]
148    ]
149    [
150        [
151            `X::hash(c)`
152        ]
153        [
154            `unsigned char`
155        ]
156        [
157            Yields a value between `0` and `UCHAR_MAX` inclusive.
158        ]
159    ]
160    [
161        [
162            `v.widen(ch)`
163        ]
164        [
165            `CharT`
166        ]
167        [
168            Widens the specified `char` and returns the resulting `CharT`.
169        ]
170    ]
171    [
172        [
173            `v.in_range(r1, r2, c)`
174        ]
175        [
176            `bool`
177        ]
178        [
179            For any characters `r1` and `r2`, returns `true` if `r1 <= c && c <= r2`.
180                Requires that `r1 <= r2`.
181        ]
182    ]
183    [
184        [
185            `v.in_range_nocase(r1, r2, c)`
186        ]
187        [
188            `bool`
189        ]
190        [
191            For characters `r1` and `r2`, returns `true` if there is some character
192                `d` for which `v.translate_nocase(d) == v.translate_nocase(c)` and
193                `r1 <= d && d <= r2`. Requires that `r1 <= r2`.
194        ]
195    ]
196    [
197        [
198            `v.translate(c)`
199        ]
200        [
201            `X::char_type`
202        ]
203        [
204            Returns a character such that for any character `d` that is to be considered
205                equivalent to `c` then `v.translate(c) == v.translate(d)`.
206        ]
207    ]
208    [
209        [
210            `v.translate_nocase(c)`
211        ]
212        [
213            `X::char_type`
214        ]
215        [
216            For all characters `C` that are to be considered
217            equivalent to `c` when comparisons are to be performed without regard to case,
218            then `v.translate_nocase(c) == v.translate_nocase(C)`.
219        ]
220    ]
221    [
222        [
223            `v.transform(F1, F2)`
224        ]
225        [
226            `X::string_type`
227        ]
228        [
229            Returns a sort key for the character sequence designated by the iterator range
230                `[F1, F2)` such that if the character sequence `[G1, G2)` sorts before the
231                character sequence `[H1, H2)` then `v.transform(G1, G2) < v.transform(H1, H2)`.
232        ]
233    ]
234    [
235        [
236            `v.transform_primary(F1, F2)`
237        ]
238        [
239            `X::string_type`
240        ]
241        [
242            Returns a sort key for the character sequence designated by the iterator range
243                `[F1, F2)` such that if the character sequence `[G1, G2)` sorts before the
244                character sequence `[H1, H2)` when character case is not considered then
245                `v.transform_primary(G1, G2) < v.transform_primary(H1, H2)`.
246        ]
247    ]
248    [
249        [
250            `v.lookup_classname(F1, F2)`
251        ]
252        [
253            `X::char_class_type`
254        ]
255        [
256            Converts the character sequence designated by the iterator range `[F1,F2)` into a
257                bitmask type that can subsequently be passed to `isctype`. Values returned from
258                `lookup_classname` can be safely bitwise or'ed together. Returns `0` if the
259                character sequence is not the name of a character class recognized by `X`. The
260                value returned shall be independent of the case of the characters in the
261                sequence.
262        ]
263    ]
264    [
265        [
266            `v.lookup_collatename(F1, F2)`
267        ]
268        [
269            `X::string_type`
270        ]
271        [
272            Returns a sequence of characters that represents the collating element
273                consisting of the character sequence designated by the iterator range `[F1, F2)`.
274                Returns an empty string if the character sequence is not a valid collating
275                element.
276        ]
277    ]
278    [
279        [
280            `v.isctype(c, v.lookup_classname(F1, F2))`
281        ]
282        [
283            `bool`
284        ]
285        [
286            Returns `true` if character `c` is a member of the character class designated by
287                the iterator range `[F1, F2)`, `false` otherwise.
288        ]
289    ]
290    [
291        [
292            `v.value(c, i)`
293        ]
294        [
295            `int`
296        ]
297        [
298            Returns the value represented by the digit `c` in base `i` if the character `c` is a
299                valid digit in base `i`; otherwise returns `-1`.\n
300                \[Note: the value of `i` will only be `8`, `10`, or `16`. -end note\]
301        ]
302    ]
303    [
304        [
305            `u.imbue(loc)`
306        ]
307        [
308            `X::locale_type`
309        ]
310        [
311            Imbues `u` with the locale `loc`, returns the previous
312                locale used by `u`.
313        ]
314    ]
315    [
316        [
317            `v.getloc()`
318        ]
319        [
320            `X::locale_type`
321        ]
322        [
323            Returns the current locale used by `v`.
324        ]
325    ]
326]
327
328[h2 Acknowledgements]
329
330This section is adapted from the equivalent page in the _regexpp_ documentation and from the
331_proposal_ to add regular expressions to the Standard Library.
332
333[endsect]
334