From Jason Turner

[re.regex]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmplu90g42j/{from.md → to.md} +65 -67
tmp/tmplu90g42j/{from.md → to.md} RENAMED
@@ -9,30 +9,31 @@ allocated and freed as necessary by the member functions of class
9
 
10
  Objects of type specialization of `basic_regex` are responsible for
11
  converting the sequence of `charT` objects to an internal
12
  representation. It is not specified what form this representation takes,
13
  nor how it is accessed by algorithms that operate on regular
14
- expressions. Implementations will typically declare some function
15
- templates as friends of `basic_regex` to achieve this
 
 
16
 
17
  The functions described in this Clause report errors by throwing
18
  exceptions of type `regex_error`.
19
 
20
  ``` cpp
21
  namespace std {
22
- template <class charT,
23
- class traits = regex_traits<charT> >
24
  class basic_regex {
25
  public:
26
  // types:
27
- typedef charT value_type;
28
- typedef traits traits_type;
29
- typedef typename traits::string_type string_type;
30
- typedef regex_constants::syntax_option_type flag_type;
31
- typedef typename traits::locale_type locale_type;
32
 
33
- // [re.regex.const], constants:
34
  static constexpr regex_constants::syntax_option_type
35
  icase = regex_constants::icase;
36
  static constexpr regex_constants::syntax_option_type
37
  nosubs = regex_constants::nosubs;
38
  static constexpr regex_constants::syntax_option_type
@@ -49,88 +50,83 @@ namespace std {
49
  awk = regex_constants::awk;
50
  static constexpr regex_constants::syntax_option_type
51
  grep = regex_constants::grep;
52
  static constexpr regex_constants::syntax_option_type
53
  egrep = regex_constants::egrep;
 
 
54
 
55
- // [re.regex.construct], construct/copy/destroy:
56
  basic_regex();
57
- explicit basic_regex(const charT* p,
58
- flag_type f = regex_constants::ECMAScript);
59
  basic_regex(const charT* p, size_t len, flag_type f = regex_constants::ECMAScript);
60
  basic_regex(const basic_regex&);
61
  basic_regex(basic_regex&&) noexcept;
62
  template <class ST, class SA>
63
  explicit basic_regex(const basic_string<charT, ST, SA>& p,
64
  flag_type f = regex_constants::ECMAScript);
65
  template <class ForwardIterator>
66
  basic_regex(ForwardIterator first, ForwardIterator last,
67
  flag_type f = regex_constants::ECMAScript);
68
- basic_regex(initializer_list<charT>,
69
- flag_type = regex_constants::ECMAScript);
70
 
71
  ~basic_regex();
72
 
73
  basic_regex& operator=(const basic_regex&);
74
  basic_regex& operator=(basic_regex&&) noexcept;
75
  basic_regex& operator=(const charT* ptr);
76
  basic_regex& operator=(initializer_list<charT> il);
77
  template <class ST, class SA>
78
  basic_regex& operator=(const basic_string<charT, ST, SA>& p);
79
 
80
- // [re.regex.assign], assign:
81
  basic_regex& assign(const basic_regex& that);
82
  basic_regex& assign(basic_regex&& that) noexcept;
83
- basic_regex& assign(const charT* ptr,
84
- flag_type f = regex_constants::ECMAScript);
85
  basic_regex& assign(const charT* p, size_t len, flag_type f);
86
  template <class string_traits, class A>
87
  basic_regex& assign(const basic_string<charT, string_traits, A>& s,
88
  flag_type f = regex_constants::ECMAScript);
89
  template <class InputIterator>
90
  basic_regex& assign(InputIterator first, InputIterator last,
91
  flag_type f = regex_constants::ECMAScript);
92
  basic_regex& assign(initializer_list<charT>,
93
  flag_type = regex_constants::ECMAScript);
94
 
95
- // [re.regex.operations], const operations:
96
  unsigned mark_count() const;
97
  flag_type flags() const;
98
 
99
- // [re.regex.locale], locale:
100
  locale_type imbue(locale_type loc);
101
  locale_type getloc() const;
102
 
103
- // [re.regex.swap], swap:
104
  void swap(basic_regex&);
105
  };
 
 
 
 
 
106
  }
107
  ```
108
 
109
  ### `basic_regex` constants <a id="re.regex.const">[[re.regex.const]]</a>
110
 
111
  ``` cpp
112
- static constexpr regex_constants::syntax_option_type
113
- icase = regex_constants::icase;
114
- static constexpr regex_constants::syntax_option_type
115
- nosubs = regex_constants::nosubs;
116
- static constexpr regex_constants::syntax_option_type
117
- optimize = regex_constants::optimize;
118
- static constexpr regex_constants::syntax_option_type
119
- collate = regex_constants::collate;
120
- static constexpr regex_constants::syntax_option_type
121
- ECMAScript = regex_constants::ECMAScript;
122
- static constexpr regex_constants::syntax_option_type
123
- basic = regex_constants::basic;
124
- static constexpr regex_constants::syntax_option_type
125
- extended = regex_constants::extended;
126
- static constexpr regex_constants::syntax_option_type
127
- awk = regex_constants::awk;
128
- static constexpr regex_constants::syntax_option_type
129
- grep = regex_constants::grep;
130
- static constexpr regex_constants::syntax_option_type
131
- egrep = regex_constants::egrep;
132
  ```
133
 
134
  The static constant members are provided as synonyms for the constants
135
  declared in namespace `regex_constants`.
136
 
@@ -145,35 +141,35 @@ match any character sequence.
145
 
146
  ``` cpp
147
  explicit basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript);
148
  ```
149
 
150
- *Requires:* *p* shall not be a null pointer.
151
 
152
- *Throws:* `regex_error` if *p* is not a valid regular expression.
153
 
154
  *Effects:* Constructs an object of class `basic_regex`; the object’s
155
  internal finite state machine is constructed from the regular expression
156
  contained in the array of `charT` of length
157
  `char_traits<charT>::length(p)` whose first element is designated by
158
- *p*, and interpreted according to the flags *f*.
159
 
160
  *Postconditions:* `flags()` returns `f`. `mark_count()` returns the
161
  number of marked sub-expressions within the expression.
162
 
163
  ``` cpp
164
  basic_regex(const charT* p, size_t len, flag_type f);
165
  ```
166
 
167
- *Requires:* *p* shall not be a null pointer.
168
 
169
- *Throws:* `regex_error` if *p* is not a valid regular expression.
170
 
171
  *Effects:* Constructs an object of class `basic_regex`; the object’s
172
  internal finite state machine is constructed from the regular expression
173
  contained in the sequence of characters \[`p`, `p+len`), and interpreted
174
- according the flags specified in *f*.
175
 
176
  *Postconditions:* `flags()` returns `f`. `mark_count()` returns the
177
  number of marked sub-expressions within the expression.
178
 
179
  ``` cpp
@@ -228,79 +224,81 @@ interpreted according to the flags specified in `f`.
228
 
229
  *Postconditions:* `flags()` returns `f`. `mark_count()` returns the
230
  number of marked sub-expressions within the expression.
231
 
232
  ``` cpp
233
- basic_regex(initializer_list<charT> il,
234
- flag_type f = regex_constants::ECMAScript);
235
  ```
236
 
237
  *Effects:* Same as `basic_regex(il.begin(), il.end(), f)`.
238
 
239
  ### `basic_regex` assign <a id="re.regex.assign">[[re.regex.assign]]</a>
240
 
241
  ``` cpp
242
  basic_regex& operator=(const basic_regex& e);
243
  ```
244
 
245
- *Effects:* returns `assign(e)`.
 
 
 
246
 
247
  ``` cpp
248
  basic_regex& operator=(basic_regex&& e) noexcept;
249
  ```
250
 
251
- *Effects:* returns `assign(std::move(e))`.
 
 
 
 
252
 
253
  ``` cpp
254
  basic_regex& operator=(const charT* ptr);
255
  ```
256
 
257
  *Requires:* `ptr` shall not be a null pointer.
258
 
259
- *Effects:* returns `assign(ptr)`.
260
 
261
  ``` cpp
262
  basic_regex& operator=(initializer_list<charT> il);
263
  ```
264
 
265
- *Effects:* returns `assign(il.begin(), il.end())`.
266
 
267
  ``` cpp
268
  template <class ST, class SA>
269
  basic_regex& operator=(const basic_string<charT, ST, SA>& p);
270
  ```
271
 
272
- *Effects:* returns `assign(p)`.
273
 
274
  ``` cpp
275
  basic_regex& assign(const basic_regex& that);
276
  ```
277
 
278
- *Effects:* copies `that` into `*this` and returns `*this`.
279
 
280
- *Postconditions:* `flags()` and `mark_count()` return `that.flags()` and
281
- `that.mark_count()`, respectively.
282
 
283
  ``` cpp
284
  basic_regex& assign(basic_regex&& that) noexcept;
285
  ```
286
 
287
- *Effects:* move assigns from `that` into `*this` and returns `*this`.
288
 
289
- *Postconditions:* `flags()` and `mark_count()` return the values that
290
- `that.flags()` and `that.mark_count()`, respectively, had before
291
- assignment. `that` is in a valid state with unspecified value.
292
 
293
  ``` cpp
294
  basic_regex& assign(const charT* ptr, flag_type f = regex_constants::ECMAScript);
295
  ```
296
 
297
  *Returns:* `assign(string_type(ptr), f)`.
298
 
299
  ``` cpp
300
- basic_regex& assign(const charT* ptr, size_t len,
301
- flag_type f = regex_constants::ECMAScript);
302
  ```
303
 
304
  *Returns:* `assign(string_type(ptr, len), f)`.
305
 
306
  ``` cpp
@@ -362,32 +360,32 @@ were passed to the object’s constructor or to the last call to `assign`.
362
  ``` cpp
363
  locale_type imbue(locale_type loc);
364
  ```
365
 
366
  *Effects:* Returns the result of `traits_inst.imbue(loc)` where
367
- `traits_inst` is a (default initialized) instance of the template type
368
  argument `traits` stored within the object. After a call to `imbue` the
369
  `basic_regex` object does not match any character sequence.
370
 
371
  ``` cpp
372
  locale_type getloc() const;
373
  ```
374
 
375
  *Effects:* Returns the result of `traits_inst.getloc()` where
376
- `traits_inst` is a (default initialized) instance of the template
377
  parameter `traits` stored within the object.
378
 
379
  ### `basic_regex` swap <a id="re.regex.swap">[[re.regex.swap]]</a>
380
 
381
  ``` cpp
382
  void swap(basic_regex& e);
383
  ```
384
 
385
  *Effects:* Swaps the contents of the two regular expressions.
386
 
387
- `*this` contains the regular expression that was in `e`, `e` contains
388
- the regular expression that was in `*this`.
389
 
390
  *Complexity:* Constant time.
391
 
392
  ### `basic_regex` non-member functions <a id="re.regex.nonmemb">[[re.regex.nonmemb]]</a>
393
 
 
9
 
10
  Objects of type specialization of `basic_regex` are responsible for
11
  converting the sequence of `charT` objects to an internal
12
  representation. It is not specified what form this representation takes,
13
  nor how it is accessed by algorithms that operate on regular
14
+ expressions.
15
+
16
+ [*Note 1*: Implementations will typically declare some function
17
+ templates as friends of `basic_regex` to achieve this — *end note*]
18
 
19
  The functions described in this Clause report errors by throwing
20
  exceptions of type `regex_error`.
21
 
22
  ``` cpp
23
  namespace std {
24
+ template <class charT, class traits = regex_traits<charT>>
 
25
  class basic_regex {
26
  public:
27
  // types:
28
+ using value_type = charT;
29
+ using traits_type = traits;
30
+ using string_type = typename traits::string_type;
31
+ using flag_type = regex_constants::syntax_option_type;
32
+ using locale_type = typename traits::locale_type;
33
 
34
+ // [re.regex.const], constants
35
  static constexpr regex_constants::syntax_option_type
36
  icase = regex_constants::icase;
37
  static constexpr regex_constants::syntax_option_type
38
  nosubs = regex_constants::nosubs;
39
  static constexpr regex_constants::syntax_option_type
 
50
  awk = regex_constants::awk;
51
  static constexpr regex_constants::syntax_option_type
52
  grep = regex_constants::grep;
53
  static constexpr regex_constants::syntax_option_type
54
  egrep = regex_constants::egrep;
55
+ static constexpr regex_constants::syntax_option_type
56
+ multiline = regex_constants::multiline;
57
 
58
+ // [re.regex.construct], construct/copy/destroy
59
  basic_regex();
60
+ explicit basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript);
 
61
  basic_regex(const charT* p, size_t len, flag_type f = regex_constants::ECMAScript);
62
  basic_regex(const basic_regex&);
63
  basic_regex(basic_regex&&) noexcept;
64
  template <class ST, class SA>
65
  explicit basic_regex(const basic_string<charT, ST, SA>& p,
66
  flag_type f = regex_constants::ECMAScript);
67
  template <class ForwardIterator>
68
  basic_regex(ForwardIterator first, ForwardIterator last,
69
  flag_type f = regex_constants::ECMAScript);
70
+ basic_regex(initializer_list<charT>, flag_type = regex_constants::ECMAScript);
 
71
 
72
  ~basic_regex();
73
 
74
  basic_regex& operator=(const basic_regex&);
75
  basic_regex& operator=(basic_regex&&) noexcept;
76
  basic_regex& operator=(const charT* ptr);
77
  basic_regex& operator=(initializer_list<charT> il);
78
  template <class ST, class SA>
79
  basic_regex& operator=(const basic_string<charT, ST, SA>& p);
80
 
81
+ // [re.regex.assign], assign
82
  basic_regex& assign(const basic_regex& that);
83
  basic_regex& assign(basic_regex&& that) noexcept;
84
+ basic_regex& assign(const charT* ptr, flag_type f = regex_constants::ECMAScript);
 
85
  basic_regex& assign(const charT* p, size_t len, flag_type f);
86
  template <class string_traits, class A>
87
  basic_regex& assign(const basic_string<charT, string_traits, A>& s,
88
  flag_type f = regex_constants::ECMAScript);
89
  template <class InputIterator>
90
  basic_regex& assign(InputIterator first, InputIterator last,
91
  flag_type f = regex_constants::ECMAScript);
92
  basic_regex& assign(initializer_list<charT>,
93
  flag_type = regex_constants::ECMAScript);
94
 
95
+ // [re.regex.operations], const operations
96
  unsigned mark_count() const;
97
  flag_type flags() const;
98
 
99
+ // [re.regex.locale], locale
100
  locale_type imbue(locale_type loc);
101
  locale_type getloc() const;
102
 
103
+ // [re.regex.swap], swap
104
  void swap(basic_regex&);
105
  };
106
+
107
+ template<class ForwardIterator>
108
+ basic_regex(ForwardIterator, ForwardIterator,
109
+ regex_constants::syntax_option_type = regex_constants::ECMAScript)
110
+ -> basic_regex<typename iterator_traits<ForwardIterator>::value_type>;
111
  }
112
  ```
113
 
114
  ### `basic_regex` constants <a id="re.regex.const">[[re.regex.const]]</a>
115
 
116
  ``` cpp
117
+ static constexpr regex_constants::syntax_option_type icase = regex_constants::icase;
118
+ static constexpr regex_constants::syntax_option_type nosubs = regex_constants::nosubs;
119
+ static constexpr regex_constants::syntax_option_type optimize = regex_constants::optimize;
120
+ static constexpr regex_constants::syntax_option_type collate = regex_constants::collate;
121
+ static constexpr regex_constants::syntax_option_type ECMAScript = regex_constants::ECMAScript;
122
+ static constexpr regex_constants::syntax_option_type basic = regex_constants::basic;
123
+ static constexpr regex_constants::syntax_option_type extended = regex_constants::extended;
124
+ static constexpr regex_constants::syntax_option_type awk = regex_constants::awk;
125
+ static constexpr regex_constants::syntax_option_type grep = regex_constants::grep;
126
+ static constexpr regex_constants::syntax_option_type egrep = regex_constants::egrep;
127
+ static constexpr regex_constants::syntax_option_type multiline = regex_constants::multiline;
 
 
 
 
 
 
 
 
 
128
  ```
129
 
130
  The static constant members are provided as synonyms for the constants
131
  declared in namespace `regex_constants`.
132
 
 
141
 
142
  ``` cpp
143
  explicit basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript);
144
  ```
145
 
146
+ *Requires:* `p` shall not be a null pointer.
147
 
148
+ *Throws:* `regex_error` if `p` is not a valid regular expression.
149
 
150
  *Effects:* Constructs an object of class `basic_regex`; the object’s
151
  internal finite state machine is constructed from the regular expression
152
  contained in the array of `charT` of length
153
  `char_traits<charT>::length(p)` whose first element is designated by
154
+ `p`, and interpreted according to the flags `f`.
155
 
156
  *Postconditions:* `flags()` returns `f`. `mark_count()` returns the
157
  number of marked sub-expressions within the expression.
158
 
159
  ``` cpp
160
  basic_regex(const charT* p, size_t len, flag_type f);
161
  ```
162
 
163
+ *Requires:* `p` shall not be a null pointer.
164
 
165
+ *Throws:* `regex_error` if `p` is not a valid regular expression.
166
 
167
  *Effects:* Constructs an object of class `basic_regex`; the object’s
168
  internal finite state machine is constructed from the regular expression
169
  contained in the sequence of characters \[`p`, `p+len`), and interpreted
170
+ according the flags specified in `f`.
171
 
172
  *Postconditions:* `flags()` returns `f`. `mark_count()` returns the
173
  number of marked sub-expressions within the expression.
174
 
175
  ``` cpp
 
224
 
225
  *Postconditions:* `flags()` returns `f`. `mark_count()` returns the
226
  number of marked sub-expressions within the expression.
227
 
228
  ``` cpp
229
+ basic_regex(initializer_list<charT> il, flag_type f = regex_constants::ECMAScript);
 
230
  ```
231
 
232
  *Effects:* Same as `basic_regex(il.begin(), il.end(), f)`.
233
 
234
  ### `basic_regex` assign <a id="re.regex.assign">[[re.regex.assign]]</a>
235
 
236
  ``` cpp
237
  basic_regex& operator=(const basic_regex& e);
238
  ```
239
 
240
+ *Effects:* Copies `e` into `*this` and returns `*this`.
241
+
242
+ *Postconditions:* `flags()` and `mark_count()` return `e.flags()` and
243
+ `e.mark_count()`, respectively.
244
 
245
  ``` cpp
246
  basic_regex& operator=(basic_regex&& e) noexcept;
247
  ```
248
 
249
+ *Effects:* Move assigns from `e` into `*this` and returns `*this`.
250
+
251
+ *Postconditions:* `flags()` and `mark_count()` return the values that
252
+ `e.flags()` and `e.mark_count()`, respectively, had before assignment.
253
+ `e` is in a valid state with unspecified value.
254
 
255
  ``` cpp
256
  basic_regex& operator=(const charT* ptr);
257
  ```
258
 
259
  *Requires:* `ptr` shall not be a null pointer.
260
 
261
+ *Effects:* Returns `assign(ptr)`.
262
 
263
  ``` cpp
264
  basic_regex& operator=(initializer_list<charT> il);
265
  ```
266
 
267
+ *Effects:* Returns `assign(il.begin(), il.end())`.
268
 
269
  ``` cpp
270
  template <class ST, class SA>
271
  basic_regex& operator=(const basic_string<charT, ST, SA>& p);
272
  ```
273
 
274
+ *Effects:* Returns `assign(p)`.
275
 
276
  ``` cpp
277
  basic_regex& assign(const basic_regex& that);
278
  ```
279
 
280
+ *Effects:* Equivalent to `*this = that`.
281
 
282
+ *Returns:* `*this`.
 
283
 
284
  ``` cpp
285
  basic_regex& assign(basic_regex&& that) noexcept;
286
  ```
287
 
288
+ *Effects:* Equivalent to `*this = std::move(that)`.
289
 
290
+ *Returns:* `*this`.
 
 
291
 
292
  ``` cpp
293
  basic_regex& assign(const charT* ptr, flag_type f = regex_constants::ECMAScript);
294
  ```
295
 
296
  *Returns:* `assign(string_type(ptr), f)`.
297
 
298
  ``` cpp
299
+ basic_regex& assign(const charT* ptr, size_t len, flag_type f = regex_constants::ECMAScript);
 
300
  ```
301
 
302
  *Returns:* `assign(string_type(ptr, len), f)`.
303
 
304
  ``` cpp
 
360
  ``` cpp
361
  locale_type imbue(locale_type loc);
362
  ```
363
 
364
  *Effects:* Returns the result of `traits_inst.imbue(loc)` where
365
+ `traits_inst` is a (default-initialized) instance of the template type
366
  argument `traits` stored within the object. After a call to `imbue` the
367
  `basic_regex` object does not match any character sequence.
368
 
369
  ``` cpp
370
  locale_type getloc() const;
371
  ```
372
 
373
  *Effects:* Returns the result of `traits_inst.getloc()` where
374
+ `traits_inst` is a (default-initialized) instance of the template
375
  parameter `traits` stored within the object.
376
 
377
  ### `basic_regex` swap <a id="re.regex.swap">[[re.regex.swap]]</a>
378
 
379
  ``` cpp
380
  void swap(basic_regex& e);
381
  ```
382
 
383
  *Effects:* Swaps the contents of the two regular expressions.
384
 
385
+ *Postconditions:* `*this` contains the regular expression that was in
386
+ `e`, `e` contains the regular expression that was in `*this`.
387
 
388
  *Complexity:* Constant time.
389
 
390
  ### `basic_regex` non-member functions <a id="re.regex.nonmemb">[[re.regex.nonmemb]]</a>
391