From Jason Turner

[re]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp59h34fjp/{from.md → to.md} +294 -104
tmp/tmp59h34fjp/{from.md → to.md} RENAMED
@@ -16,11 +16,10 @@ summarized in [[re.summary]].
16
 
17
  **Table: Regular expressions library summary** <a id="re.summary">[re.summary]</a>
18
 
19
  | Subclause | | Header |
20
  | --------------- | --------------------------- | --------- |
21
- | [[re.def]] | Definitions | |
22
  | [[re.req]] | Requirements | |
23
  | [[re.const]] | Constants | `<regex>` |
24
  | [[re.badexp]] | Exception type | |
25
  | [[re.traits]] | Traits | |
26
  | [[re.regex]] | Regular expression template | |
@@ -29,50 +28,10 @@ summarized in [[re.summary]].
29
  | [[re.alg]] | Algorithms | |
30
  | [[re.iter]] | Iterators | |
31
  | [[re.grammar]] | Grammar | |
32
 
33
 
34
- ## Definitions <a id="re.def">[[re.def]]</a>
35
-
36
- The following definitions shall apply to this Clause:
37
-
38
- #### 1 collating element <a id="defns.regex.collating.element">[[defns.regex.collating.element]]</a>
39
-
40
- a sequence of one or more characters within the current locale that
41
- collate as if they were a single character.
42
-
43
- #### 2 finite state machine <a id="defns.regex.finite.state.machine">[[defns.regex.finite.state.machine]]</a>
44
-
45
- an unspecified data structure that is used to represent a regular
46
- expression, and which permits efficient matches against the regular
47
- expression to be obtained.
48
-
49
- #### 3 format specifier <a id="defns.regex.format.specifier">[[defns.regex.format.specifier]]</a>
50
-
51
- a sequence of one or more characters that is to be replaced with some
52
- part of a regular expression match.
53
-
54
- #### 4 matched <a id="defns.regex.matched">[[defns.regex.matched]]</a>
55
-
56
- a sequence of zero or more characters is matched by a regular expression
57
- when the characters in the sequence correspond to a sequence of
58
- characters defined by the pattern.
59
-
60
- #### 5 primary equivalence class <a id="defns.regex.primary.equivalence.class">[[defns.regex.primary.equivalence.class]]</a>
61
-
62
- a set of one or more characters which share the same primary sort key:
63
- that is the sort key weighting that depends only upon character shape,
64
- and not accents, case, or locale specific tailorings.
65
-
66
- #### 6 regular expression <a id="defns.regex.regular.expression">[[defns.regex.regular.expression]]</a>
67
-
68
- a pattern that selects specific strings from a set of character strings.
69
-
70
- #### 7 sub-expression <a id="defns.regex.subexpression">[[defns.regex.subexpression]]</a>
71
-
72
- a subset of a regular expression that has been marked by parenthesis.
73
-
74
  ## Requirements <a id="re.req">[[re.req]]</a>
75
 
76
  This subclause defines requirements on classes representing regular
77
  expression traits.
78
 
@@ -88,24 +47,175 @@ of these members.
88
 
89
  To specialize class template `basic_regex` for a character container
90
  `CharT` and its related regular expression traits class `Traits`, use
91
  `basic_regex<CharT, Traits>`.
92
 
93
- In [[re.req]] `X` denotes a traits class defining types and functions
94
- for the character container type `charT`; `u` is an object of type `X`;
95
- `v` is an object of type `const
96
- X`; `p` is a value of type `const charT*`; `I1` and `I2` are input
97
- iterators [[input.iterators]]; `F1` and `F2` are forward iterators
98
- [[forward.iterators]]; `c` is a value of type `const charT`; `s` is an
99
- object of type `X::string_type`; `cs` is an object of type
100
- `const X::string_type`; `b` is a value of type `bool`; `I` is a value of
101
- type `int`; `cl` is an object of type `X::char_class_type`, and `loc` is
102
- an object of type `X::locale_type`.
103
-
104
- [*Note 2*: The value of *I* will only be 8, 10, or 16. — *end note*]
105
-
106
- [*Note 3*: Class template `regex_traits` meets the requirements for a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  regular expression traits class when it is specialized for `char` or
108
  `wchar_t`. This class template is described in the header `<regex>`, and
109
  is described in [[re.traits]]. — *end note*]
110
 
111
  ## Header `<regex>` synopsis <a id="re.syn">[[re.syn]]</a>
@@ -349,10 +459,12 @@ namespace std {
349
  }
350
  ```
351
 
352
  ## Namespace `std::regex_constants` <a id="re.const">[[re.const]]</a>
353
 
 
 
354
  The namespace `std::regex_constants` holds symbolic constants used by
355
  the regular expression library. This namespace provides three types,
356
  `syntax_option_type`, `match_flag_type`, and `error_type`, along with
357
  several constants of these types.
358
 
@@ -387,18 +499,18 @@ grammar is `ECMAScript`.
387
  | Element | Effect(s) if set |
388
  | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
389
  | % `icase` | Specifies that matching of regular expressions against a character container sequence shall be performed without regard to case. \indexlibrarymember{syntax_option_type}{icase}% |
390
  | % `nosubs` | Specifies that no sub-expressions shall be considered to be marked, so that when a regular expression is matched against a character container sequence, no sub-expression matches shall be stored in the supplied `match_results` object. \indexlibrarymember{syntax_option_type}{nosubs}% |
391
  | % `optimize` | Specifies that the regular expression engine should pay more attention to the speed with which regular expressions are matched, and less to the speed with which regular expression objects are constructed. Otherwise it has no detectable effect on the program output. \indexlibrarymember{syntax_option_type}{optimize}% |
392
- | % `collate` | Specifies that character ranges of the form `"[a-b]"` shall be locale sensitive. \indexlibrarymember{syntax_option_type}{collate}% \indextext{locale}% |
393
  | % `ECMAScript` | Specifies that the grammar recognized by the regular expression engine shall be that used by ECMAScript in ECMA-262, as modified in~ [[re.grammar]]. \xref ECMA-262 15.10 \indextext{ECMAScript}% \indexlibrarymember{syntax_option_type}{ECMAScript}% |
394
  | % `basic` | Specifies that the grammar recognized by the regular expression engine shall be that used by basic regular expressions in POSIX. \xref POSIX, Base Definitions and Headers, Section 9.3 \indextext{POSIX!regular expressions}% \indexlibrarymember{syntax_option_type}{basic}% |
395
  | % `extended` | Specifies that the grammar recognized by the regular expression engine shall be that used by extended regular expressions in POSIX. \xref POSIX, Base Definitions and Headers, Section 9.4 \indextext{POSIX!extended regular expressions}% \indexlibrarymember{syntax_option_type}{extended}% |
396
- | % `awk` | Specifies that the grammar recognized by the regular expression engine shall be that used by the utility awk in POSIX. \indextext{\idxcode{awk}}% \indexlibrarymember{syntax_option_type}{awk}% |
397
- | % `grep` | Specifies that the grammar recognized by the regular expression engine shall be that used by the utility grep in POSIX. \indextext{\idxcode{grep}}% \indexlibrarymember{syntax_option_type}{grep}% |
398
- | % `egrep` | Specifies that the grammar recognized by the regular expression engine shall be that used by the utility grep when given the -E option in POSIX. \indextext{\idxcode{egrep}}% \indexlibrarymember{syntax_option_type}{egrep}% |
399
- | % `multiline` | Specifies that `^` shall match the beginning of a line and `$` shall match the end of a line, if the `ECMAScript` engine is selected. \indextext{\idxcode{multiline}}% \indexlibrarymember{syntax_option_type}{multiline}% |
400
 
401
 
402
  ### Bitmask type `match_flag_type` <a id="re.matchflag">[[re.matchflag]]</a>
403
 
404
  ``` cpp
@@ -474,34 +586,36 @@ The type `error_type` is an *implementation-defined* enumerated type
474
  conditions described in [[re.err]]:
475
 
476
  **Table: `error_type` values in the C locale** <a id="re.err">[re.err]</a>
477
 
478
  | Value | Error condition |
479
- | -------------------- | ----------------------------------------------------------------------------------------------------------------------- |
480
- | `error_collate` | The expression contained an invalid collating element name. |
481
- | % `error_ctype` | The expression contained an invalid character class name. |
482
- | % `error_escape` | The expression contained an invalid escaped character, or a trailing escape. |
483
- | % `error_backref` | The expression contained an invalid back reference. |
484
- | % `error_brack` | The expression contained mismatched \verb|[| and \verb|]|. |
485
- | % `error_paren` | The expression contained mismatched \verb|(| and \verb|)|. |
486
- | % `error_brace` | The expression contained mismatched \verb|{| and \verb|}| |
487
- | % `error_badbrace` | The expression contained an invalid range in a \verb|{}| expression. |
488
- | % `error_range` | The expression contained an invalid character range, such as \verb|[b-a]| in most encodings. |
489
- | % `error_space` | There was insufficient memory to convert the expression into a finite state machine. |
490
- | % `error_badrepeat` | One of \verb|*?+{| was not preceded by a valid regular expression. |
491
- | % `error_complexity` | The complexity of an attempted match against a regular expression exceeded a pre-set level. |
492
- | % `error_stack` | There was insufficient memory to determine whether the regular expression could match the specified character sequence. |
493
 
494
 
495
  ## Class `regex_error` <a id="re.badexp">[[re.badexp]]</a>
496
 
497
  ``` cpp
 
498
  class regex_error : public runtime_error {
499
  public:
500
  explicit regex_error(regex_constants::error_type ecode);
501
  regex_constants::error_type code() const;
502
  };
 
503
  ```
504
 
505
  The class `regex_error` defines the type of objects thrown as exceptions
506
  to report errors from the regular expression library.
507
 
@@ -628,13 +742,14 @@ template<class ForwardIterator>
628
  *Returns:* An unspecified value that represents the character
629
  classification named by the character sequence designated by the
630
  iterator range \[`first`, `last`). If the parameter `icase` is `true`
631
  then the returned mask identifies the character classification without
632
  regard to the case of the characters being matched, otherwise it does
633
- honor the case of the characters being matched.[^1] The value returned
634
- shall be independent of the case of the characters in the character
635
- sequence. If the name is not recognized then returns
 
636
  `char_class_type()`.
637
 
638
  *Remarks:* For `regex_traits<char>`, at least the narrow character names
639
  in [[re.traits.classnames]] shall be recognized. For
640
  `regex_traits<wchar_t>`, at least the wide character names in
@@ -719,16 +834,16 @@ locale_type imbue(locale_type loc);
719
 
720
  [*Note 1*: Calling `imbue` with a different locale than the one
721
  currently in use invalidates all cached data held by
722
  `*this`. — *end note*]
723
 
 
 
724
  *Returns:* If no locale has been previously imbued then a copy of the
725
  global locale in effect at the time of construction of `*this`,
726
  otherwise a copy of the last argument passed to `imbue`.
727
 
728
- *Ensures:* `getloc() == loc`.
729
-
730
  ``` cpp
731
  locale_type getloc() const;
732
  ```
733
 
734
  *Returns:* If no locale has been imbued then a copy of the global locale
@@ -756,10 +871,12 @@ the last argument passed to `imbue`.
756
  | `"xdigit"` | `L"xdigit"` | `ctype_base::xdigit` |
757
 
758
 
759
  ## Class template `basic_regex` <a id="re.regex">[[re.regex]]</a>
760
 
 
 
761
  For a char-like type `charT`, specializations of class template
762
  `basic_regex` represent regular expressions constructed from character
763
  sequences of `charT` characters. In the rest of  [[re.regex]], `charT`
764
  denotes a given char-like type. Storage for a regular expression is
765
  allocated and freed as necessary by the member functions of class
@@ -772,11 +889,11 @@ nor how it is accessed by algorithms that operate on regular
772
  expressions.
773
 
774
  [*Note 1*: Implementations will typically declare some function
775
  templates as friends of `basic_regex` to achieve this. — *end note*]
776
 
777
- The functions described in this Clause report errors by throwing
778
  exceptions of type `regex_error`.
779
 
780
  ``` cpp
781
  namespace std {
782
  template<class charT, class traits = regex_traits<charT>>
@@ -1016,20 +1133,20 @@ basic_regex& assign(const charT* p, size_t len, flag_type f = regex_constants::E
1016
  template<class ST, class SA>
1017
  basic_regex& assign(const basic_string<charT, ST, SA>& s,
1018
  flag_type f = regex_constants::ECMAScript);
1019
  ```
1020
 
1021
- *Returns:* `*this`.
1022
-
1023
  *Effects:* Assigns the regular expression contained in the string `s`,
1024
  interpreted according the flags specified in `f`. If an exception is
1025
  thrown, `*this` is unchanged.
1026
 
1027
  *Ensures:* If no exception is thrown, `flags()` returns `f` and
1028
  `mark_count()` returns the number of marked sub-expressions within the
1029
  expression.
1030
 
 
 
1031
  *Throws:* `regex_error` if `s` is not a valid regular expression.
1032
 
1033
  ``` cpp
1034
  template<class InputIterator>
1035
  basic_regex& assign(InputIterator first, InputIterator last,
@@ -1102,10 +1219,12 @@ template<class charT, class traits>
1102
 
1103
  *Effects:* Calls `lhs.swap(rhs)`.
1104
 
1105
  ## Class template `sub_match` <a id="re.submatch">[[re.submatch]]</a>
1106
 
 
 
1107
  Class template `sub_match` denotes the sequence of characters matched by
1108
  a particular marked sub-expression.
1109
 
1110
  ``` cpp
1111
  namespace std {
@@ -1128,10 +1247,12 @@ namespace std {
1128
  string_type str() const;
1129
 
1130
  int compare(const sub_match& s) const;
1131
  int compare(const string_type& s) const;
1132
  int compare(const value_type* s) const;
 
 
1133
  };
1134
  }
1135
  ```
1136
 
1137
  ### Members <a id="re.submatch.members">[[re.submatch.members]]</a>
@@ -1177,10 +1298,27 @@ int compare(const string_type& s) const;
1177
  int compare(const value_type* s) const;
1178
  ```
1179
 
1180
  *Returns:* `str().compare(s)`.
1181
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1182
  ### Non-member operators <a id="re.submatch.op">[[re.submatch.op]]</a>
1183
 
1184
  Let `SM-CAT(I)` be
1185
 
1186
  ``` cpp
@@ -1278,22 +1416,24 @@ template<class charT, class ST, class BiIter>
1278
 
1279
  *Returns:* `os << m.str()`.
1280
 
1281
  ## Class template `match_results` <a id="re.results">[[re.results]]</a>
1282
 
 
 
1283
  Class template `match_results` denotes a collection of character
1284
  sequences representing the result of a regular expression match. Storage
1285
  for the collection is allocated and freed as necessary by the member
1286
  functions of class template `match_results`.
1287
 
1288
  The class template `match_results` meets the requirements of an
1289
- allocator-aware container and of a sequence container (
1290
- [[container.requirements.general]], [[sequence.reqmts]]) except that
1291
- only copy assignment, move assignment, and operations defined for
1292
  const-qualified sequence containers are supported and that the semantics
1293
- of comparison functions are different from those required for a
1294
- container.
1295
 
1296
  A default-constructed `match_results` object has no fully established
1297
  result state. A match result is *ready* when, as a consequence of a
1298
  completed regular expression match modifying such an object, its result
1299
  state becomes fully established. The effects of calling most member
@@ -1320,11 +1460,11 @@ namespace std {
1320
  class match_results {
1321
  public:
1322
  using value_type = sub_match<BidirectionalIterator>;
1323
  using const_reference = const value_type&;
1324
  using reference = value_type&;
1325
- using const_iterator = {implementation-defined};
1326
  using iterator = const_iterator;
1327
  using difference_type =
1328
  typename iterator_traits<BidirectionalIterator>::difference_type;
1329
  using size_type = typename allocator_traits<Allocator>::size_type;
1330
  using allocator_type = Allocator;
@@ -1332,13 +1472,15 @@ namespace std {
1332
  typename iterator_traits<BidirectionalIterator>::value_type;
1333
  using string_type = basic_string<char_type>;
1334
 
1335
  // [re.results.const], construct/copy/destroy
1336
  match_results() : match_results(Allocator()) {}
1337
- explicit match_results(const Allocator&);
1338
  match_results(const match_results& m);
 
1339
  match_results(match_results&& m) noexcept;
 
1340
  match_results& operator=(const match_results& m);
1341
  match_results& operator=(match_results&& m);
1342
  ~match_results();
1343
 
1344
  // [re.results.state], state
@@ -1390,25 +1532,48 @@ namespace std {
1390
  }
1391
  ```
1392
 
1393
  ### Constructors <a id="re.results.const">[[re.results.const]]</a>
1394
 
 
 
 
 
 
1395
  ``` cpp
1396
  explicit match_results(const Allocator& a);
1397
  ```
1398
 
 
 
1399
  *Ensures:* `ready()` returns `false`. `size()` returns `0`.
1400
 
 
 
 
 
 
 
 
 
 
 
 
1401
  ``` cpp
1402
  match_results(match_results&& m) noexcept;
 
1403
  ```
1404
 
1405
- *Effects:* The stored `Allocator` value is move constructed from
1406
- `m.get_allocator()`.
 
1407
 
1408
  *Ensures:* As specified in [[re.results.const]].
1409
 
 
 
 
1410
  ``` cpp
1411
  match_results& operator=(const match_results& m);
1412
  ```
1413
 
1414
  *Ensures:* As specified in [[re.results.const]].
@@ -1417,22 +1582,22 @@ match_results& operator=(const match_results& m);
1417
  match_results& operator=(match_results&& m);
1418
  ```
1419
 
1420
  *Ensures:* As specified in [[re.results.const]].
1421
 
1422
- **Table: `match_results` assignment operator effects** <a id="re.results.const">[re.results.const]</a>
1423
 
1424
  | Element | Value |
1425
- | ------------- | ----------------------------------------------- |
1426
  | `ready()` | `m.ready()` |
1427
  | `size()` | `m.size()` |
1428
- | `str(n)` | `m.str(n)` for all integers `n < m.size()` |
1429
  | `prefix()` | `m.prefix()` |
1430
  | `suffix()` | `m.suffix()` |
1431
- | `(*this)[n]` | `m[n]` for all integers `n < m.size()` |
1432
- | `length(n)` | `m.length(n)` for all integers `n < m.size()` |
1433
- | `position(n)` | `m.position(n)` for all integers `n < m.size()` |
1434
 
1435
 
1436
  ### State <a id="re.results.state">[[re.results.state]]</a>
1437
 
1438
  ``` cpp
@@ -1689,12 +1854,12 @@ template<class BidirectionalIterator, class Allocator, class charT, class traits
1689
  match_results<BidirectionalIterator, Allocator>& m,
1690
  const basic_regex<charT, traits>& e,
1691
  regex_constants::match_flag_type flags = regex_constants::match_default);
1692
  ```
1693
 
1694
- *Preconditions:* `BidirectionalIterator` meets the
1695
- *Cpp17BidirectionalIterator* requirements [[bidirectional.iterators]].
1696
 
1697
  *Effects:* Determines whether there is a match between the regular
1698
  expression `e`, and all of the character sequence \[`first`, `last`).
1699
  The parameter `flags` is used to control how the expression is matched
1700
  against the character sequence. When determining if there is a match,
@@ -1798,12 +1963,12 @@ template<class BidirectionalIterator, class Allocator, class charT, class traits
1798
  match_results<BidirectionalIterator, Allocator>& m,
1799
  const basic_regex<charT, traits>& e,
1800
  regex_constants::match_flag_type flags = regex_constants::match_default);
1801
  ```
1802
 
1803
- *Preconditions:* `BidirectionalIterator` meets the
1804
- *Cpp17BidirectionalIterator* requirements [[bidirectional.iterators]].
1805
 
1806
  *Effects:* Determines whether there is some sub-sequence within
1807
  \[`first`, `last`) that matches the regular expression `e`. The
1808
  parameter `flags` is used to control how the expression is matched
1809
  against the character sequence. Returns `true` if such a sequence
@@ -2000,10 +2165,12 @@ regex_replace(back_inserter(result), s, s + char_traits<charT>::length(s), e, fm
2000
 
2001
  ## Regular expression iterators <a id="re.iter">[[re.iter]]</a>
2002
 
2003
  ### Class template `regex_iterator` <a id="re.regiter">[[re.regiter]]</a>
2004
 
 
 
2005
  The class template `regex_iterator` is an iterator adaptor. It
2006
  represents a new view of an existing iterator sequence, by enumerating
2007
  all the occurrences of a regular expression within that sequence. A
2008
  `regex_iterator` uses `regex_search` to find successive regular
2009
  expression matches within the sequence from which it was constructed.
@@ -2030,10 +2197,11 @@ namespace std {
2030
  class traits = regex_traits<charT>>
2031
  class regex_iterator {
2032
  public:
2033
  using regex_type = basic_regex<charT, traits>;
2034
  using iterator_category = forward_iterator_tag;
 
2035
  using value_type = match_results<BidirectionalIterator>;
2036
  using difference_type = ptrdiff_t;
2037
  using pointer = const value_type*;
2038
  using reference = const value_type&;
2039
 
@@ -2045,10 +2213,11 @@ namespace std {
2045
  const regex_type&&,
2046
  regex_constants::match_flag_type = regex_constants::match_default) = delete;
2047
  regex_iterator(const regex_iterator&);
2048
  regex_iterator& operator=(const regex_iterator&);
2049
  bool operator==(const regex_iterator&) const;
 
2050
  const value_type& operator*() const;
2051
  const value_type* operator->() const;
2052
  regex_iterator& operator++();
2053
  regex_iterator operator++(int);
2054
 
@@ -2163,11 +2332,11 @@ the beginning of the target sequence, which is often not the same as the
2163
  offset from the sequence passed in the call to
2164
  `regex_search`. — *end note*]
2165
 
2166
  It is unspecified how the implementation makes these adjustments.
2167
 
2168
- [*Note 2*: This means that a compiler may call an
2169
  implementation-specific search function, in which case a program-defined
2170
  specialization of `regex_search` will not be called. — *end note*]
2171
 
2172
  ``` cpp
2173
  regex_iterator operator++(int);
@@ -2181,10 +2350,12 @@ regex_iterator tmp = *this;
2181
  return tmp;
2182
  ```
2183
 
2184
  ### Class template `regex_token_iterator` <a id="re.tokiter">[[re.tokiter]]</a>
2185
 
 
 
2186
  The class template `regex_token_iterator` is an iterator adaptor; that
2187
  is to say it represents a new view of an existing iterator sequence, by
2188
  enumerating all the occurrences of a regular expression within that
2189
  sequence, and presenting one or more sub-expressions for each match
2190
  found. Each position enumerated by the iterator is a `sub_match` class
@@ -2233,10 +2404,11 @@ namespace std {
2233
  class traits = regex_traits<charT>>
2234
  class regex_token_iterator {
2235
  public:
2236
  using regex_type = basic_regex<charT, traits>;
2237
  using iterator_category = forward_iterator_tag;
 
2238
  using value_type = sub_match<BidirectionalIterator>;
2239
  using difference_type = ptrdiff_t;
2240
  using pointer = const value_type*;
2241
  using reference = const value_type&;
2242
 
@@ -2284,10 +2456,11 @@ namespace std {
2284
  regex_constants::match_flag_type m =
2285
  regex_constants::match_default) = delete;
2286
  regex_token_iterator(const regex_token_iterator&);
2287
  regex_token_iterator& operator=(const regex_token_iterator&);
2288
  bool operator==(const regex_token_iterator&) const;
 
2289
  const value_type& operator*() const;
2290
  const value_type* operator->() const;
2291
  regex_token_iterator& operator++();
2292
  regex_token_iterator operator++(int);
2293
 
@@ -2450,31 +2623,41 @@ ClassAtom::
2450
  '-'
2451
  ClassAtomNoDash
2452
  ClassAtomExClass
2453
  ClassAtomCollatingElement
2454
  ClassAtomEquivalence
 
2455
 
 
2456
  IdentityEscape::
2457
  SourceCharacter but not 'c'
2458
  ```
2459
 
2460
  The following new productions are then added:
2461
 
2462
  ``` bnf
2463
  ClassAtomExClass::
2464
  '[:' ClassName ':]'
 
2465
 
 
2466
  ClassAtomCollatingElement::
2467
  '[.' ClassName '.]'
 
2468
 
 
2469
  ClassAtomEquivalence::
2470
  '[=' ClassName '=]'
 
2471
 
 
2472
  ClassName::
2473
  ClassNameCharacter
2474
  ClassNameCharacter ClassName
 
2475
 
 
2476
  ClassNameCharacter::
2477
  SourceCharacter but not one of '.' or '=' or ':'
2478
  ```
2479
 
2480
  The productions , and provide functionality equivalent to that of the
@@ -2589,66 +2772,73 @@ as follows:
2589
 
2590
  ECMA-262 15.10
2591
 
2592
  <!-- Link reference definitions -->
2593
  [algorithms]: algorithms.md#algorithms
2594
- [bidirectional.iterators]: iterators.md#bidirectional.iterators
2595
  [bitmask.types]: library.md#bitmask.types
 
2596
  [container.requirements.general]: containers.md#container.requirements.general
2597
  [enumerated.types]: library.md#enumerated.types
2598
  [forward.iterators]: iterators.md#forward.iterators
2599
  [input.iterators]: iterators.md#input.iterators
 
2600
  [output.iterators]: iterators.md#output.iterators
2601
  [re]: #re
2602
  [re.alg]: #re.alg
2603
  [re.alg.match]: #re.alg.match
2604
  [re.alg.replace]: #re.alg.replace
2605
  [re.alg.search]: #re.alg.search
2606
  [re.badexp]: #re.badexp
2607
  [re.const]: #re.const
2608
- [re.def]: #re.def
2609
  [re.err]: #re.err
2610
  [re.except]: #re.except
2611
  [re.general]: #re.general
2612
  [re.grammar]: #re.grammar
2613
  [re.iter]: #re.iter
2614
  [re.matchflag]: #re.matchflag
2615
  [re.regex]: #re.regex
2616
  [re.regex.assign]: #re.regex.assign
2617
  [re.regex.construct]: #re.regex.construct
 
2618
  [re.regex.locale]: #re.regex.locale
2619
  [re.regex.nonmemb]: #re.regex.nonmemb
2620
  [re.regex.operations]: #re.regex.operations
2621
  [re.regex.swap]: #re.regex.swap
2622
  [re.regiter]: #re.regiter
2623
  [re.regiter.cnstr]: #re.regiter.cnstr
2624
  [re.regiter.comp]: #re.regiter.comp
2625
  [re.regiter.deref]: #re.regiter.deref
 
2626
  [re.regiter.incr]: #re.regiter.incr
2627
  [re.req]: #re.req
2628
  [re.results]: #re.results
2629
  [re.results.acc]: #re.results.acc
2630
  [re.results.all]: #re.results.all
2631
  [re.results.const]: #re.results.const
2632
  [re.results.form]: #re.results.form
 
2633
  [re.results.nonmember]: #re.results.nonmember
2634
  [re.results.size]: #re.results.size
2635
  [re.results.state]: #re.results.state
2636
  [re.results.swap]: #re.results.swap
2637
  [re.submatch]: #re.submatch
 
2638
  [re.submatch.members]: #re.submatch.members
2639
  [re.submatch.op]: #re.submatch.op
2640
  [re.summary]: #re.summary
2641
  [re.syn]: #re.syn
2642
  [re.synopt]: #re.synopt
2643
  [re.tokiter]: #re.tokiter
2644
  [re.tokiter.cnstr]: #re.tokiter.cnstr
2645
  [re.tokiter.comp]: #re.tokiter.comp
2646
  [re.tokiter.deref]: #re.tokiter.deref
 
2647
  [re.tokiter.incr]: #re.tokiter.incr
2648
  [re.traits]: #re.traits
2649
  [re.traits.classnames]: #re.traits.classnames
2650
  [sequence.reqmts]: containers.md#sequence.reqmts
2651
  [strings.general]: strings.md#strings.general
 
2652
 
2653
  [^1]: For example, if the parameter `icase` is `true` then `[[:lower:]]`
2654
  is the same as `[[:alpha:]]`.
 
16
 
17
  **Table: Regular expressions library summary** <a id="re.summary">[re.summary]</a>
18
 
19
  | Subclause | | Header |
20
  | --------------- | --------------------------- | --------- |
 
21
  | [[re.req]] | Requirements | |
22
  | [[re.const]] | Constants | `<regex>` |
23
  | [[re.badexp]] | Exception type | |
24
  | [[re.traits]] | Traits | |
25
  | [[re.regex]] | Regular expression template | |
 
28
  | [[re.alg]] | Algorithms | |
29
  | [[re.iter]] | Iterators | |
30
  | [[re.grammar]] | Grammar | |
31
 
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  ## Requirements <a id="re.req">[[re.req]]</a>
34
 
35
  This subclause defines requirements on classes representing regular
36
  expression traits.
37
 
 
47
 
48
  To specialize class template `basic_regex` for a character container
49
  `CharT` and its related regular expression traits class `Traits`, use
50
  `basic_regex<CharT, Traits>`.
51
 
52
+ In the following requirements,
53
+
54
+ - `X` denotes a traits class defining types and functions for the
55
+ character container type `charT`;
56
+ - `u` is an object of type `X`;
57
+ - `v` is an object of type `const X`;
58
+ - `p` is a value of type `const charT*`;
59
+ - `I1` and `I2` are input iterators [[input.iterators]];
60
+ - `F1` and `F2` are forward iterators [[forward.iterators]];
61
+ - `c` is a value of type `const charT`;
62
+ - `s` is an object of type `X::string_type`;
63
+ - `cs` is an object of type `const X::string_type`;
64
+ - `b` is a value of type `bool`;
65
+ - `I` is a value of type `int`;
66
+ - `cl` is an object of type `X::char_class_type`; and
67
+ - `loc` is an object of type `X::locale_type`.
68
+
69
+ A traits class `X` meets the regular expression traits requirements if
70
+ the following types and expressions are well-formed and have the
71
+ specified semantics.
72
+
73
+ ``` cpp
74
+ typename X::char_type
75
+ ```
76
+
77
+ *Result:* `charT`, the character container type used in the
78
+ implementation of class template `basic_regex`.
79
+
80
+ ``` cpp
81
+ typename X::string_type
82
+ ```
83
+
84
+ *Result:* `basic_string<charT>`
85
+
86
+ ``` cpp
87
+ typename X::locale_type
88
+ ```
89
+
90
+ *Result:* A copy constructible type that represents the locale used by
91
+ the traits class.
92
+
93
+ ``` cpp
94
+ typename X::char_class_type
95
+ ```
96
+
97
+ *Result:* A bitmask type [[bitmask.types]] representing a particular
98
+ character classification.
99
+
100
+ ``` cpp
101
+ X::length(p)
102
+ ```
103
+
104
+ *Result:* `size_t`
105
+
106
+ *Returns:* The smallest `i` such that `p[i] == 0`.
107
+
108
+ *Complexity:* Linear in `i`.
109
+
110
+ ``` cpp
111
+ v.translate(c)
112
+ ```
113
+
114
+ *Result:* `X::char_type`
115
+
116
+ *Returns:* A character such that for any character `d` that is to be
117
+ considered equivalent to `c` then `v.translate(c) == v.translate(d)`.
118
+
119
+ ``` cpp
120
+ v.translate_nocase(c)
121
+ ```
122
+
123
+ *Result:* `X::char_type`
124
+
125
+ *Returns:* For all characters `C` that are to be considered equivalent
126
+ to `c` when comparisons are to be performed without regard to case, then
127
+ `v.translate_nocase(c) == v.translate_nocase(C)`.
128
+
129
+ ``` cpp
130
+ v.transform(F1, F2)
131
+ ```
132
+
133
+ *Result:* `X::string_type`
134
+
135
+ *Returns:* A sort key for the character sequence designated by the
136
+ iterator range \[`F1`, `F2`) such that if the character sequence \[`G1`,
137
+ `G2`) sorts before the character sequence \[`H1`, `H2`) then
138
+ `v.transform(G1, G2) < v.transform(H1, H2)`.
139
+
140
+ ``` cpp
141
+ v.transform_primary(F1, F2)
142
+ ```
143
+
144
+ *Result:* `X::string_type`
145
+
146
+ *Returns:* A sort key for the character sequence designated by the
147
+ iterator range \[`F1`, `F2`) such that if the character sequence \[`G1`,
148
+ `G2`) sorts before the character sequence \[`H1`, `H2`) when character
149
+ case is not considered then
150
+ `v.transform_primary(G1, G2) < v.transform_primary(H1, H2)`.
151
+
152
+ ``` cpp
153
+ v.lookup_collatename(F1, F2)
154
+ ```
155
+
156
+ *Result:* `X::string_type`
157
+
158
+ *Returns:* A sequence of characters that represents the collating
159
+ element consisting of the character sequence designated by the iterator
160
+ range \[`F1`, `F2`). Returns an empty string if the character sequence
161
+ is not a valid collating element.
162
+
163
+ ``` cpp
164
+ v.lookup_classname(F1, F2, b)
165
+ ```
166
+
167
+ *Result:* `X::char_class_type`
168
+
169
+ *Returns:* Converts the character sequence designated by the iterator
170
+ range \[`F1`, `F2`) into a value of a bitmask type that can subsequently
171
+ be passed to `isctype`. Values returned from `lookup_classname` can be
172
+ bitwise ’ed together; the resulting value represents membership in
173
+ either of the corresponding character classes. If `b` is `true`, the
174
+ returned bitmask is suitable for matching characters without regard to
175
+ their case. Returns `0` if the character sequence is not the name of a
176
+ character class recognized by `X`. The value returned shall be
177
+ independent of the case of the characters in the sequence.
178
+
179
+ ``` cpp
180
+ v.isctype(c, cl)
181
+ ```
182
+
183
+ *Result:* `bool`
184
+
185
+ *Returns:* Returns `true` if character `c` is a member of one of the
186
+ character classes designated by `cl`, `false` otherwise.
187
+
188
+ ``` cpp
189
+ v.value(c, I)
190
+ ```
191
+
192
+ *Result:* `int`
193
+
194
+ *Returns:* Returns the value represented by the digit *c* in base *I* if
195
+ the character *c* is a valid digit in base *I*; otherwise returns `-1`.
196
+
197
+ [*Note 1*: The value of *I* will only be 8, 10, or 16. — *end note*]
198
+
199
+ ``` cpp
200
+ u.imbue(loc)
201
+ ```
202
+
203
+ *Result:* `X::locale_type`
204
+
205
+ *Effects:* Imbues `u` with the locale `loc` and returns the previous
206
+ locale used by `u` if any.
207
+
208
+ ``` cpp
209
+ v.getloc()
210
+ ```
211
+
212
+ *Result:* `X::locale_type`
213
+
214
+ *Returns:* Returns the current locale used by `v`, if any.
215
+
216
+ [*Note 2*: Class template `regex_traits` meets the requirements for a
217
  regular expression traits class when it is specialized for `char` or
218
  `wchar_t`. This class template is described in the header `<regex>`, and
219
  is described in [[re.traits]]. — *end note*]
220
 
221
  ## Header `<regex>` synopsis <a id="re.syn">[[re.syn]]</a>
 
459
  }
460
  ```
461
 
462
  ## Namespace `std::regex_constants` <a id="re.const">[[re.const]]</a>
463
 
464
+ ### General <a id="re.const.general">[[re.const.general]]</a>
465
+
466
  The namespace `std::regex_constants` holds symbolic constants used by
467
  the regular expression library. This namespace provides three types,
468
  `syntax_option_type`, `match_flag_type`, and `error_type`, along with
469
  several constants of these types.
470
 
 
499
  | Element | Effect(s) if set |
500
  | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
501
  | % `icase` | Specifies that matching of regular expressions against a character container sequence shall be performed without regard to case. \indexlibrarymember{syntax_option_type}{icase}% |
502
  | % `nosubs` | Specifies that no sub-expressions shall be considered to be marked, so that when a regular expression is matched against a character container sequence, no sub-expression matches shall be stored in the supplied `match_results` object. \indexlibrarymember{syntax_option_type}{nosubs}% |
503
  | % `optimize` | Specifies that the regular expression engine should pay more attention to the speed with which regular expressions are matched, and less to the speed with which regular expression objects are constructed. Otherwise it has no detectable effect on the program output. \indexlibrarymember{syntax_option_type}{optimize}% |
504
+ | % `collate` | Specifies that character ranges of the form `"[a-b]"` shall be locale sensitive.% \indexlibrarymember{syntax_option_type}{collate}% \indextext{locale}% |
505
  | % `ECMAScript` | Specifies that the grammar recognized by the regular expression engine shall be that used by ECMAScript in ECMA-262, as modified in~ [[re.grammar]]. \xref ECMA-262 15.10 \indextext{ECMAScript}% \indexlibrarymember{syntax_option_type}{ECMAScript}% |
506
  | % `basic` | Specifies that the grammar recognized by the regular expression engine shall be that used by basic regular expressions in POSIX. \xref POSIX, Base Definitions and Headers, Section 9.3 \indextext{POSIX!regular expressions}% \indexlibrarymember{syntax_option_type}{basic}% |
507
  | % `extended` | Specifies that the grammar recognized by the regular expression engine shall be that used by extended regular expressions in POSIX. \xref POSIX, Base Definitions and Headers, Section 9.4 \indextext{POSIX!extended regular expressions}% \indexlibrarymember{syntax_option_type}{extended}% |
508
+ | % `awk` | Specifies that the grammar recognized by the regular expression engine shall be that used by the utility awk in POSIX. \indexlibrarymember{syntax_option_type}{awk}% |
509
+ | % `grep` | Specifies that the grammar recognized by the regular expression engine shall be that used by the utility grep in POSIX. \indexlibrarymember{syntax_option_type}{grep}% |
510
+ | % `egrep` | Specifies that the grammar recognized by the regular expression engine shall be that used by the utility grep when given the -E option in POSIX. \indexlibrarymember{syntax_option_type}{egrep}% |
511
+ | % `multiline` | Specifies that `^` shall match the beginning of a line and `$` shall match the end of a line, if the `ECMAScript` engine is selected. \indexlibrarymember{syntax_option_type}{multiline}% |
512
 
513
 
514
  ### Bitmask type `match_flag_type` <a id="re.matchflag">[[re.matchflag]]</a>
515
 
516
  ``` cpp
 
586
  conditions described in [[re.err]]:
587
 
588
  **Table: `error_type` values in the C locale** <a id="re.err">[re.err]</a>
589
 
590
  | Value | Error condition |
591
+ | -------------------- | ------------------------------------------------------------------------------------------------------------------ |
592
+ | `error_collate` | The expression contains an invalid collating element name. |
593
+ | % `error_ctype` | The expression contains an invalid character class name. |
594
+ | % `error_escape` | The expression contains an invalid escaped character, or a trailing escape. |
595
+ | % `error_backref` | The expression contains an invalid back reference. |
596
+ | % `error_brack` | The expression contains mismatched \verb|[| and \verb|]|. |
597
+ | % `error_paren` | The expression contains mismatched \verb|(| and \verb|)|. |
598
+ | % `error_brace` | The expression contains mismatched \verb|{| and \verb|}| |
599
+ | % `error_badbrace` | The expression contains an invalid range in a \verb|{}| expression. |
600
+ | % `error_range` | The expression contains an invalid character range, such as \verb|[b-a]| in most encodings. |
601
+ | % `error_space` | There is insufficient memory to convert the expression into a finite state machine. |
602
+ | % `error_badrepeat` | One of \verb|*?+{| is not preceded by a valid regular expression. |
603
+ | % `error_complexity` | The complexity of an attempted match against a regular expression exceeds a pre-set level. |
604
+ | % `error_stack` | There is insufficient memory to determine whether the regular expression matches the specified character sequence. |
605
 
606
 
607
  ## Class `regex_error` <a id="re.badexp">[[re.badexp]]</a>
608
 
609
  ``` cpp
610
+ namespace std {
611
  class regex_error : public runtime_error {
612
  public:
613
  explicit regex_error(regex_constants::error_type ecode);
614
  regex_constants::error_type code() const;
615
  };
616
+ }
617
  ```
618
 
619
  The class `regex_error` defines the type of objects thrown as exceptions
620
  to report errors from the regular expression library.
621
 
 
742
  *Returns:* An unspecified value that represents the character
743
  classification named by the character sequence designated by the
744
  iterator range \[`first`, `last`). If the parameter `icase` is `true`
745
  then the returned mask identifies the character classification without
746
  regard to the case of the characters being matched, otherwise it does
747
+ honor the case of the characters being matched.[^1]
748
+
749
+ The value returned shall be independent of the case of the characters in
750
+ the character sequence. If the name is not recognized then returns
751
  `char_class_type()`.
752
 
753
  *Remarks:* For `regex_traits<char>`, at least the narrow character names
754
  in [[re.traits.classnames]] shall be recognized. For
755
  `regex_traits<wchar_t>`, at least the wide character names in
 
834
 
835
  [*Note 1*: Calling `imbue` with a different locale than the one
836
  currently in use invalidates all cached data held by
837
  `*this`. — *end note*]
838
 
839
+ *Ensures:* `getloc() == loc`.
840
+
841
  *Returns:* If no locale has been previously imbued then a copy of the
842
  global locale in effect at the time of construction of `*this`,
843
  otherwise a copy of the last argument passed to `imbue`.
844
 
 
 
845
  ``` cpp
846
  locale_type getloc() const;
847
  ```
848
 
849
  *Returns:* If no locale has been imbued then a copy of the global locale
 
871
  | `"xdigit"` | `L"xdigit"` | `ctype_base::xdigit` |
872
 
873
 
874
  ## Class template `basic_regex` <a id="re.regex">[[re.regex]]</a>
875
 
876
+ ### General <a id="re.regex.general">[[re.regex.general]]</a>
877
+
878
  For a char-like type `charT`, specializations of class template
879
  `basic_regex` represent regular expressions constructed from character
880
  sequences of `charT` characters. In the rest of  [[re.regex]], `charT`
881
  denotes a given char-like type. Storage for a regular expression is
882
  allocated and freed as necessary by the member functions of class
 
889
  expressions.
890
 
891
  [*Note 1*: Implementations will typically declare some function
892
  templates as friends of `basic_regex` to achieve this. — *end note*]
893
 
894
+ The functions described in [[re.regex]] report errors by throwing
895
  exceptions of type `regex_error`.
896
 
897
  ``` cpp
898
  namespace std {
899
  template<class charT, class traits = regex_traits<charT>>
 
1133
  template<class ST, class SA>
1134
  basic_regex& assign(const basic_string<charT, ST, SA>& s,
1135
  flag_type f = regex_constants::ECMAScript);
1136
  ```
1137
 
 
 
1138
  *Effects:* Assigns the regular expression contained in the string `s`,
1139
  interpreted according the flags specified in `f`. If an exception is
1140
  thrown, `*this` is unchanged.
1141
 
1142
  *Ensures:* If no exception is thrown, `flags()` returns `f` and
1143
  `mark_count()` returns the number of marked sub-expressions within the
1144
  expression.
1145
 
1146
+ *Returns:* `*this`.
1147
+
1148
  *Throws:* `regex_error` if `s` is not a valid regular expression.
1149
 
1150
  ``` cpp
1151
  template<class InputIterator>
1152
  basic_regex& assign(InputIterator first, InputIterator last,
 
1219
 
1220
  *Effects:* Calls `lhs.swap(rhs)`.
1221
 
1222
  ## Class template `sub_match` <a id="re.submatch">[[re.submatch]]</a>
1223
 
1224
+ ### General <a id="re.submatch.general">[[re.submatch.general]]</a>
1225
+
1226
  Class template `sub_match` denotes the sequence of characters matched by
1227
  a particular marked sub-expression.
1228
 
1229
  ``` cpp
1230
  namespace std {
 
1247
  string_type str() const;
1248
 
1249
  int compare(const sub_match& s) const;
1250
  int compare(const string_type& s) const;
1251
  int compare(const value_type* s) const;
1252
+
1253
+ void swap(sub_match& s) noexcept(see below);
1254
  };
1255
  }
1256
  ```
1257
 
1258
  ### Members <a id="re.submatch.members">[[re.submatch.members]]</a>
 
1298
  int compare(const value_type* s) const;
1299
  ```
1300
 
1301
  *Returns:* `str().compare(s)`.
1302
 
1303
+ ``` cpp
1304
+ void swap(sub_match& s) noexcept(see below);
1305
+ ```
1306
+
1307
+ *Preconditions:* `BidirectionalIterator` meets the *Cpp17Swappable*
1308
+ requirements [[swappable.requirements]].
1309
+
1310
+ *Effects:* Equivalent to:
1311
+
1312
+ ``` cpp
1313
+ this->pair<BidirectionalIterator, BidirectionalIterator>::swap(s);
1314
+ std::swap(matched, s.matched);
1315
+ ```
1316
+
1317
+ *Remarks:* The exception specification is equivalent to
1318
+ `is_nothrow_swappable_v<BidirectionalIterator>`.
1319
+
1320
  ### Non-member operators <a id="re.submatch.op">[[re.submatch.op]]</a>
1321
 
1322
  Let `SM-CAT(I)` be
1323
 
1324
  ``` cpp
 
1416
 
1417
  *Returns:* `os << m.str()`.
1418
 
1419
  ## Class template `match_results` <a id="re.results">[[re.results]]</a>
1420
 
1421
+ ### General <a id="re.results.general">[[re.results.general]]</a>
1422
+
1423
  Class template `match_results` denotes a collection of character
1424
  sequences representing the result of a regular expression match. Storage
1425
  for the collection is allocated and freed as necessary by the member
1426
  functions of class template `match_results`.
1427
 
1428
  The class template `match_results` meets the requirements of an
1429
+ allocator-aware container and of a sequence container
1430
+ [[container.requirements.general]], [[sequence.reqmts]] except that only
1431
+ copy assignment, move assignment, and operations defined for
1432
  const-qualified sequence containers are supported and that the semantics
1433
+ of the comparison operator functions are different from those required
1434
+ for a container.
1435
 
1436
  A default-constructed `match_results` object has no fully established
1437
  result state. A match result is *ready* when, as a consequence of a
1438
  completed regular expression match modifying such an object, its result
1439
  state becomes fully established. The effects of calling most member
 
1460
  class match_results {
1461
  public:
1462
  using value_type = sub_match<BidirectionalIterator>;
1463
  using const_reference = const value_type&;
1464
  using reference = value_type&;
1465
+ using const_iterator = implementation-defined // type of match_results::const_iterator;
1466
  using iterator = const_iterator;
1467
  using difference_type =
1468
  typename iterator_traits<BidirectionalIterator>::difference_type;
1469
  using size_type = typename allocator_traits<Allocator>::size_type;
1470
  using allocator_type = Allocator;
 
1472
  typename iterator_traits<BidirectionalIterator>::value_type;
1473
  using string_type = basic_string<char_type>;
1474
 
1475
  // [re.results.const], construct/copy/destroy
1476
  match_results() : match_results(Allocator()) {}
1477
+ explicit match_results(const Allocator& a);
1478
  match_results(const match_results& m);
1479
+ match_results(const match_results& m, const Allocator& a);
1480
  match_results(match_results&& m) noexcept;
1481
+ match_results(match_results&& m, const Allocator& a);
1482
  match_results& operator=(const match_results& m);
1483
  match_results& operator=(match_results&& m);
1484
  ~match_results();
1485
 
1486
  // [re.results.state], state
 
1532
  }
1533
  ```
1534
 
1535
  ### Constructors <a id="re.results.const">[[re.results.const]]</a>
1536
 
1537
+ [[re.results.const]] lists the postconditions of `match_results`
1538
+ copy/move constructors and copy/move assignment operators. For move
1539
+ operations, the results of the expressions depending on the parameter
1540
+ `m` denote the values they had before the respective function calls.
1541
+
1542
  ``` cpp
1543
  explicit match_results(const Allocator& a);
1544
  ```
1545
 
1546
+ *Effects:* The stored `Allocator` value is constructed from `a`.
1547
+
1548
  *Ensures:* `ready()` returns `false`. `size()` returns `0`.
1549
 
1550
+ ``` cpp
1551
+ match_results(const match_results& m);
1552
+ match_results(const match_results& m, const Allocator& a);
1553
+ ```
1554
+
1555
+ *Effects:* For the first form, the stored `Allocator` value is obtained
1556
+ as specified in [[container.reqmts]]. For the second form, the stored
1557
+ `Allocator` value is constructed from `a`.
1558
+
1559
+ *Ensures:* As specified in [[re.results.const]].
1560
+
1561
  ``` cpp
1562
  match_results(match_results&& m) noexcept;
1563
+ match_results(match_results&& m, const Allocator& a);
1564
  ```
1565
 
1566
+ *Effects:* For the first form, the stored `Allocator` value is move
1567
+ constructed from `m.get_allocator()`. For the second form, the stored
1568
+ `Allocator` value is constructed from `a`.
1569
 
1570
  *Ensures:* As specified in [[re.results.const]].
1571
 
1572
+ *Throws:* The second form throws nothing if `a == m.get_allocator()` is
1573
+ `true`.
1574
+
1575
  ``` cpp
1576
  match_results& operator=(const match_results& m);
1577
  ```
1578
 
1579
  *Ensures:* As specified in [[re.results.const]].
 
1582
  match_results& operator=(match_results&& m);
1583
  ```
1584
 
1585
  *Ensures:* As specified in [[re.results.const]].
1586
 
1587
+ **Table: `match_results` copy/move operation postconditions** <a id="re.results.const">[re.results.const]</a>
1588
 
1589
  | Element | Value |
1590
+ | ------------- | ------------------------------------------------------------ |
1591
  | `ready()` | `m.ready()` |
1592
  | `size()` | `m.size()` |
1593
+ | `str(n)` | `m.str(n)` for all non-negative integers `n < m.size()` |
1594
  | `prefix()` | `m.prefix()` |
1595
  | `suffix()` | `m.suffix()` |
1596
+ | `(*this)[n]` | `m[n]` for all non-negative integers `n < m.size()` |
1597
+ | `length(n)` | `m.length(n)` for all non-negative integers `n < m.size()` |
1598
+ | `position(n)` | `m.position(n)` for all non-negative integers `n < m.size()` |
1599
 
1600
 
1601
  ### State <a id="re.results.state">[[re.results.state]]</a>
1602
 
1603
  ``` cpp
 
1854
  match_results<BidirectionalIterator, Allocator>& m,
1855
  const basic_regex<charT, traits>& e,
1856
  regex_constants::match_flag_type flags = regex_constants::match_default);
1857
  ```
1858
 
1859
+ *Preconditions:* `BidirectionalIterator` models `bidirectional_iterator`
1860
+ [[iterator.concept.bidir]].
1861
 
1862
  *Effects:* Determines whether there is a match between the regular
1863
  expression `e`, and all of the character sequence \[`first`, `last`).
1864
  The parameter `flags` is used to control how the expression is matched
1865
  against the character sequence. When determining if there is a match,
 
1963
  match_results<BidirectionalIterator, Allocator>& m,
1964
  const basic_regex<charT, traits>& e,
1965
  regex_constants::match_flag_type flags = regex_constants::match_default);
1966
  ```
1967
 
1968
+ *Preconditions:* `BidirectionalIterator` models `bidirectional_iterator`
1969
+ [[iterator.concept.bidir]].
1970
 
1971
  *Effects:* Determines whether there is some sub-sequence within
1972
  \[`first`, `last`) that matches the regular expression `e`. The
1973
  parameter `flags` is used to control how the expression is matched
1974
  against the character sequence. Returns `true` if such a sequence
 
2165
 
2166
  ## Regular expression iterators <a id="re.iter">[[re.iter]]</a>
2167
 
2168
  ### Class template `regex_iterator` <a id="re.regiter">[[re.regiter]]</a>
2169
 
2170
+ #### General <a id="re.regiter.general">[[re.regiter.general]]</a>
2171
+
2172
  The class template `regex_iterator` is an iterator adaptor. It
2173
  represents a new view of an existing iterator sequence, by enumerating
2174
  all the occurrences of a regular expression within that sequence. A
2175
  `regex_iterator` uses `regex_search` to find successive regular
2176
  expression matches within the sequence from which it was constructed.
 
2197
  class traits = regex_traits<charT>>
2198
  class regex_iterator {
2199
  public:
2200
  using regex_type = basic_regex<charT, traits>;
2201
  using iterator_category = forward_iterator_tag;
2202
+ using iterator_concept = input_iterator_tag;
2203
  using value_type = match_results<BidirectionalIterator>;
2204
  using difference_type = ptrdiff_t;
2205
  using pointer = const value_type*;
2206
  using reference = const value_type&;
2207
 
 
2213
  const regex_type&&,
2214
  regex_constants::match_flag_type = regex_constants::match_default) = delete;
2215
  regex_iterator(const regex_iterator&);
2216
  regex_iterator& operator=(const regex_iterator&);
2217
  bool operator==(const regex_iterator&) const;
2218
+ bool operator==(default_sentinel_t) const { return *this == regex_iterator(); }
2219
  const value_type& operator*() const;
2220
  const value_type* operator->() const;
2221
  regex_iterator& operator++();
2222
  regex_iterator operator++(int);
2223
 
 
2332
  offset from the sequence passed in the call to
2333
  `regex_search`. — *end note*]
2334
 
2335
  It is unspecified how the implementation makes these adjustments.
2336
 
2337
+ [*Note 2*: This means that an implementation can call an
2338
  implementation-specific search function, in which case a program-defined
2339
  specialization of `regex_search` will not be called. — *end note*]
2340
 
2341
  ``` cpp
2342
  regex_iterator operator++(int);
 
2350
  return tmp;
2351
  ```
2352
 
2353
  ### Class template `regex_token_iterator` <a id="re.tokiter">[[re.tokiter]]</a>
2354
 
2355
+ #### General <a id="re.tokiter.general">[[re.tokiter.general]]</a>
2356
+
2357
  The class template `regex_token_iterator` is an iterator adaptor; that
2358
  is to say it represents a new view of an existing iterator sequence, by
2359
  enumerating all the occurrences of a regular expression within that
2360
  sequence, and presenting one or more sub-expressions for each match
2361
  found. Each position enumerated by the iterator is a `sub_match` class
 
2404
  class traits = regex_traits<charT>>
2405
  class regex_token_iterator {
2406
  public:
2407
  using regex_type = basic_regex<charT, traits>;
2408
  using iterator_category = forward_iterator_tag;
2409
+ using iterator_concept = input_iterator_tag;
2410
  using value_type = sub_match<BidirectionalIterator>;
2411
  using difference_type = ptrdiff_t;
2412
  using pointer = const value_type*;
2413
  using reference = const value_type&;
2414
 
 
2456
  regex_constants::match_flag_type m =
2457
  regex_constants::match_default) = delete;
2458
  regex_token_iterator(const regex_token_iterator&);
2459
  regex_token_iterator& operator=(const regex_token_iterator&);
2460
  bool operator==(const regex_token_iterator&) const;
2461
+ bool operator==(default_sentinel_t) const { return *this == regex_token_iterator(); }
2462
  const value_type& operator*() const;
2463
  const value_type* operator->() const;
2464
  regex_token_iterator& operator++();
2465
  regex_token_iterator operator++(int);
2466
 
 
2623
  '-'
2624
  ClassAtomNoDash
2625
  ClassAtomExClass
2626
  ClassAtomCollatingElement
2627
  ClassAtomEquivalence
2628
+ ```
2629
 
2630
+ ``` bnf
2631
  IdentityEscape::
2632
  SourceCharacter but not 'c'
2633
  ```
2634
 
2635
  The following new productions are then added:
2636
 
2637
  ``` bnf
2638
  ClassAtomExClass::
2639
  '[:' ClassName ':]'
2640
+ ```
2641
 
2642
+ ``` bnf
2643
  ClassAtomCollatingElement::
2644
  '[.' ClassName '.]'
2645
+ ```
2646
 
2647
+ ``` bnf
2648
  ClassAtomEquivalence::
2649
  '[=' ClassName '=]'
2650
+ ```
2651
 
2652
+ ``` bnf
2653
  ClassName::
2654
  ClassNameCharacter
2655
  ClassNameCharacter ClassName
2656
+ ```
2657
 
2658
+ ``` bnf
2659
  ClassNameCharacter::
2660
  SourceCharacter but not one of '.' or '=' or ':'
2661
  ```
2662
 
2663
  The productions , and provide functionality equivalent to that of the
 
2772
 
2773
  ECMA-262 15.10
2774
 
2775
  <!-- Link reference definitions -->
2776
  [algorithms]: algorithms.md#algorithms
 
2777
  [bitmask.types]: library.md#bitmask.types
2778
+ [container.reqmts]: containers.md#container.reqmts
2779
  [container.requirements.general]: containers.md#container.requirements.general
2780
  [enumerated.types]: library.md#enumerated.types
2781
  [forward.iterators]: iterators.md#forward.iterators
2782
  [input.iterators]: iterators.md#input.iterators
2783
+ [iterator.concept.bidir]: iterators.md#iterator.concept.bidir
2784
  [output.iterators]: iterators.md#output.iterators
2785
  [re]: #re
2786
  [re.alg]: #re.alg
2787
  [re.alg.match]: #re.alg.match
2788
  [re.alg.replace]: #re.alg.replace
2789
  [re.alg.search]: #re.alg.search
2790
  [re.badexp]: #re.badexp
2791
  [re.const]: #re.const
2792
+ [re.const.general]: #re.const.general
2793
  [re.err]: #re.err
2794
  [re.except]: #re.except
2795
  [re.general]: #re.general
2796
  [re.grammar]: #re.grammar
2797
  [re.iter]: #re.iter
2798
  [re.matchflag]: #re.matchflag
2799
  [re.regex]: #re.regex
2800
  [re.regex.assign]: #re.regex.assign
2801
  [re.regex.construct]: #re.regex.construct
2802
+ [re.regex.general]: #re.regex.general
2803
  [re.regex.locale]: #re.regex.locale
2804
  [re.regex.nonmemb]: #re.regex.nonmemb
2805
  [re.regex.operations]: #re.regex.operations
2806
  [re.regex.swap]: #re.regex.swap
2807
  [re.regiter]: #re.regiter
2808
  [re.regiter.cnstr]: #re.regiter.cnstr
2809
  [re.regiter.comp]: #re.regiter.comp
2810
  [re.regiter.deref]: #re.regiter.deref
2811
+ [re.regiter.general]: #re.regiter.general
2812
  [re.regiter.incr]: #re.regiter.incr
2813
  [re.req]: #re.req
2814
  [re.results]: #re.results
2815
  [re.results.acc]: #re.results.acc
2816
  [re.results.all]: #re.results.all
2817
  [re.results.const]: #re.results.const
2818
  [re.results.form]: #re.results.form
2819
+ [re.results.general]: #re.results.general
2820
  [re.results.nonmember]: #re.results.nonmember
2821
  [re.results.size]: #re.results.size
2822
  [re.results.state]: #re.results.state
2823
  [re.results.swap]: #re.results.swap
2824
  [re.submatch]: #re.submatch
2825
+ [re.submatch.general]: #re.submatch.general
2826
  [re.submatch.members]: #re.submatch.members
2827
  [re.submatch.op]: #re.submatch.op
2828
  [re.summary]: #re.summary
2829
  [re.syn]: #re.syn
2830
  [re.synopt]: #re.synopt
2831
  [re.tokiter]: #re.tokiter
2832
  [re.tokiter.cnstr]: #re.tokiter.cnstr
2833
  [re.tokiter.comp]: #re.tokiter.comp
2834
  [re.tokiter.deref]: #re.tokiter.deref
2835
+ [re.tokiter.general]: #re.tokiter.general
2836
  [re.tokiter.incr]: #re.tokiter.incr
2837
  [re.traits]: #re.traits
2838
  [re.traits.classnames]: #re.traits.classnames
2839
  [sequence.reqmts]: containers.md#sequence.reqmts
2840
  [strings.general]: strings.md#strings.general
2841
+ [swappable.requirements]: library.md#swappable.requirements
2842
 
2843
  [^1]: For example, if the parameter `icase` is `true` then `[[:lower:]]`
2844
  is the same as `[[:alpha:]]`.