From Jason Turner

[re]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp31ar2wo4/{from.md → to.md} +265 -139
tmp/tmp31ar2wo4/{from.md → to.md} RENAMED
@@ -79,30 +79,31 @@ expression traits. The class template `regex_traits`, defined in Clause 
79
 
80
  The class template `basic_regex`, defined in Clause  [[re.regex]], needs
81
  a set of related types and functions to complete the definition of its
82
  semantics. These types and functions are provided as a set of member
83
  typedefs and functions in the template parameter `traits` used by the
84
- `basic_regex` class template. This subclause defines the semantics
85
- guaranteed by these members.
86
 
87
  To specialize class template `basic_regex` for a character container
88
  `CharT` and its related regular expression traits class `Traits`, use
89
  `basic_regex<CharT, Traits>`.
90
 
91
  In Table  [[tab:re:RegexpTraits]] `X` denotes a traits class defining
92
  types and functions for the character container type `charT`; `u` is an
93
  object of type `X`; `v` is an object of type `const
94
- X`; `p` is a value of type `const charT*`; `I1` and `I2` are Input
95
- Iterators; `F1` and `F2` are forward iterators; `c` is a value of type
96
- `const charT`; `s` is an object of type `X::string_type`; `cs` is an
97
- object of type `const X::string_type`; `b` is a value of type `bool`;
98
- `I` is a value of type `int`; `cl` is an object of type
99
- `X::char_class_type`, and loc is an object of type `X::locale_type`.
 
100
 
101
  Class template `regex_traits` satisfies the requirements for a regular
102
  expression traits class when it is specialized for `char` or `wchar_t`.
103
- This Class template is described in the header `<regex>`, and is
104
  described in Clause  [[re.traits]].
105
 
106
  ## Header `<regex>` synopsis <a id="re.syn">[[re.syn]]</a>
107
 
108
  ``` cpp
@@ -344,10 +345,18 @@ namespace std {
344
  typename basic_string<charT, ST, SA>::const_iterator,
345
  Allocator>& m,
346
  const basic_regex<charT, traits>& e,
347
  regex_constants::match_flag_type flags =
348
  regex_constants::match_default);
 
 
 
 
 
 
 
 
349
  template <class charT, class traits>
350
  bool regex_match(const charT* str,
351
  const basic_regex<charT, traits>& e,
352
  regex_constants::match_flag_type flags =
353
  regex_constants::match_default);
@@ -392,10 +401,18 @@ namespace std {
392
  typename basic_string<charT, ST, SA>::const_iterator,
393
  Allocator>& m,
394
  const basic_regex<charT, traits>& e,
395
  regex_constants::match_flag_type flags =
396
  regex_constants::match_default);
 
 
 
 
 
 
 
 
397
 
398
  // [re.alg.replace], function template regex_replace:
399
  template <class OutputIterator, class BidirectionalIterator,
400
  class traits, class charT, class ST, class SA>
401
  OutputIterator
@@ -481,114 +498,118 @@ several constants of these types.
481
 
482
  ``` cpp
483
  namespace std {
484
  namespace regex_constants {
485
  typedef T1 syntax_option_type;
486
- static constexpr syntax_option_type icase = unspecified;
487
- static constexpr syntax_option_type nosubs = unspecified;
488
- static constexpr syntax_option_type optimize = unspecified;
489
- static constexpr syntax_option_type collate = unspecified;
490
- static constexpr syntax_option_type ECMAScript = unspecified;
491
- static constexpr syntax_option_type basic = unspecified;
492
- static constexpr syntax_option_type extended = unspecified;
493
- static constexpr syntax_option_type awk = unspecified;
494
- static constexpr syntax_option_type grep = unspecified;
495
- static constexpr syntax_option_type egrep = unspecified;
496
  }
497
  }
498
  ```
499
 
500
  The type `syntax_option_type` is an implementation-defined bitmask
501
  type ([[bitmask.types]]). Setting its elements has the effects listed
502
  in table  [[tab:re:syntaxoption]]. A valid value of type
503
- `syntax_option_type` shall have exactly one of the elements
504
- `ECMAScript`, `basic`, `extended`, `awk`, `grep`, `egrep`, set.
 
505
 
506
  **Table: `syntax_option_type` effects** <a id="tab:re:syntaxoption">[tab:re:syntaxoption]</a>
507
 
508
  | Element | Effect(s) if set |
509
- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
510
- | % icase | Specifies that matching of regular expressions against a character container sequence shall be performed without regard to case. \indexlibrary{\idxcode{syntax_option_type}!\idxcode{icase}}% |
511
- | % nosubs | Specifies that when a regular expression is matched against a character container sequence, no sub-expression matches shall be stored in the supplied match_results structure. \indexlibrary{\idxcode{syntax_option_type}!\idxcode{nosubs}}% |
512
- | % 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. \indexlibrary{\idxcode{syntax_option_type}!\idxcode{optimize}}% |
513
- | % collate | Specifies that character ranges of the form `"[a-b]"` shall be locale sensitive. \indexlibrary{\idxcode{syntax_option_type}!\idxcode{collate}}% \indextext{locale}% |
514
- | % 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]]. \indextext{ECMAScript}% \indexlibrary{\idxcode{syntax_option_type}!\idxcode{ECMAScript}}% |
515
- | % basic | Specifies that the grammar recognized by the regular expression engine shall be that used by basic regular expressions in POSIX, Base Definitions and Headers, Section 9, Regular Expressions. \indextext{POSIX!regular expressions}% \indexlibrary{\idxcode{syntax_option_type}!\idxcode{basic}}% |
516
- | % extended | Specifies that the grammar recognized by the regular expression engine shall be that used by extended regular expressions in POSIX, Base Definitions and Headers, Section 9, Regular Expressions. \indextext{POSIX!extended regular expressions}% \indexlibrary{\idxcode{syntax_option_type}!\idxcode{extended}}% |
517
- | % awk | Specifies that the grammar recognized by the regular expression engine shall be that used by the utility awk in POSIX. \indextext{\idxcode{awk}}% \indexlibrary{\idxcode{syntax_option_type}!\idxcode{awk}}% |
518
- | % grep | Specifies that the grammar recognized by the regular expression engine shall be that used by the utility grep in POSIX. \indextext{\idxcode{grep}}% \indexlibrary{\idxcode{syntax_option_type}!\idxcode{grep}}% |
519
- | % 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}}% \indexlibrary{\idxcode{syntax_option_type}!\idxcode{egrep}}% |
520
 
521
 
522
  ### Bitmask type `regex_constants::match_flag_type` <a id="re.matchflag">[[re.matchflag]]</a>
523
 
524
  ``` cpp
525
  namespace std {
526
  namespace regex_constants{
527
  typedef T2 match_flag_type;
528
- static constexpr match_flag_type match_default = 0
529
- static constexpr match_flag_type match_not_bol = unspecified;
530
- static constexpr match_flag_type match_not_eol = unspecified;
531
- static constexpr match_flag_type match_not_bow = unspecified;
532
- static constexpr match_flag_type match_not_eow = unspecified;
533
- static constexpr match_flag_type match_any = unspecified;
534
- static constexpr match_flag_type match_not_null = unspecified;
535
- static constexpr match_flag_type match_continuous = unspecified;
536
- static constexpr match_flag_type match_prev_avail = unspecified;
537
- static constexpr match_flag_type format_default = 0;
538
- static constexpr match_flag_type format_sed = unspecified;
539
- static constexpr match_flag_type format_no_copy = unspecified;
540
- static constexpr match_flag_type format_first_only = unspecified;
541
  }
542
  }
543
  ```
544
 
545
  The type `regex_constants::match_flag_type` is an implementation-defined
546
- bitmask type ([[bitmask.types]]). Matching a regular expression against
547
- a sequence of characters \[`first`, `last`) proceeds according to the
548
- rules of the grammar specified for the regular expression object,
549
- modified according to the effects listed in Table  [[tab:re:matchflag]]
550
- for any bitmask elements set.
 
 
 
551
 
552
  **Table: `regex_constants::match_flag_type` effects when obtaining a match against a
553
  character container sequence {[}`first`, `last`{)}.** <a id="tab:re:matchflag">[tab:re:matchflag]</a>
554
 
555
  | Element | Effect(s) if set |
556
- | --------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
557
- | % \indexlibrary{\idxcode{match_not_bol}}% match_not_bol | The first character in the sequence {[}`first`, `last`{)} shall be treated as though it is not at the beginning of a line, so the character \verb|^| in the regular expression shall not match {[}`first`, `first`{)}. |
558
- | % \indexlibrary{\idxcode{match_not_eol}}% match_not_eol | The last character in the sequence {[}`first`, `last`{)} shall be treated as though it is not at the end of a line, so the character \verb|"$"| in the regular expression shall not match {[}`last`, `last`{)}. |
559
- | % \indexlibrary{\idxcode{match_not_bow}}% match_not_bow | The expression \verb|"\b"| shall not match the sub-sequence {[}`first`, `first`{)}. |
560
- | % \indexlibrary{\idxcode{match_not_eow}}% match_not_eow | The expression \verb|"\b"| shall not match the sub-sequence {[}`last`, `last`{)}. |
561
- | % \indexlibrary{\idxcode{match_any}}% match_any | If more than one match is possible then any match is an acceptable result. |
562
- | % \indexlibrary{\idxcode{match_not_null}}% match_not_null | The expression shall not match an empty sequence. |
563
- | % \indexlibrary{\idxcode{match_continuous}}% match_continuous | The expression shall only match a sub-sequence that begins at `first`. |
564
- | % \indexlibrary{\idxcode{match_prev_avail}}% match_prev_avail | \verb!--first! is a valid iterator position. When this flag is set the flags match_not_bol and match_not_bow shall be ignored by the regular expression algorithms~ [[re.alg]] and iterators~ [[re.iter]]. |
565
- | % \indexlibrary{\idxcode{format_default}}% format_default | When a regular expression match is to be replaced by a new string, the new string shall be constructed using the rules used by the ECMAScript replace function in ECMA-262, part 15.5.4.11 String.prototype.replace. In addition, during search and replace operations all non-overlapping occurrences of the regular expression shall be located and replaced, and sections of the input that did not match the expression shall be copied unchanged to the output string. |
566
- | % \indexlibrary{\idxcode{format_sed}}% format_sed | When a regular expression match is to be replaced by a new string, the new string shall be constructed using the rules used by the sed utility in POSIX. |
567
- | % \indexlibrary{\idxcode{format_no_copy}}% format_no_copy | During a search and replace operation, sections of the character container sequence being searched that do not match the regular expression shall not be copied to the output string. |
568
- | % \indexlibrary{\idxcode{format_first_only}}% format_first_only | When specified during a search and replace operation, only the first occurrence of the regular expression shall be replaced. |
569
 
570
 
571
  ### Implementation-defined `error_type` <a id="re.err">[[re.err]]</a>
572
 
573
  ``` cpp
574
  namespace std {
575
  namespace regex_constants {
576
  typedef T3 error_type;
577
- static constexpr error_type error_collate = unspecified;
578
- static constexpr error_type error_ctype = unspecified;
579
- static constexpr error_type error_escape = unspecified;
580
- static constexpr error_type error_backref = unspecified;
581
- static constexpr error_type error_brack = unspecified;
582
- static constexpr error_type error_paren = unspecified;
583
- static constexpr error_type error_brace = unspecified;
584
- static constexpr error_type error_badbrace = unspecified;
585
- static constexpr error_type error_range = unspecified;
586
- static constexpr error_type error_space = unspecified;
587
- static constexpr error_type error_badrepeat = unspecified;
588
- static constexpr error_type error_complexity = unspecified;
589
- static constexpr error_type error_stack = unspecified;
590
  }
591
  }
592
  ```
593
 
594
  The type `error_type` is an *implementation-defined* enumerated type (
@@ -752,38 +773,71 @@ classification named by the character sequence designated by the
752
  iterator range \[`first`, `last`). If the parameter `icase` is true then
753
  the returned mask identifies the character classification without regard
754
  to the case of the characters being matched, otherwise it does honor the
755
  case of the characters being matched.[^1] The value returned shall be
756
  independent of the case of the characters in the character sequence. If
757
- the name is not recognized then returns a value that compares equal to
758
- 0.
759
 
760
- *Remarks:* For `regex_traits<char>`, at least the names `"d"`, `"w"`,
761
- `"s"`, `"alnum"`, `"alpha"`, `"blank"`, `"cntrl"`, `"digit"`, `"graph"`,
762
- `"lower"`, `"print"`, `"punct"`, `"space"`, `"upper"` and `"xdigit"`
763
- shall be recognized. For `regex_traits<wchar_t>`, at least the names
764
- `L"d"`, `L"w"`, `L"s"`, `L"alnum"`, `L"alpha"`, `L"blank"`, `L"cntrl"`,
765
- `L"digit"`, `L"graph"`, `L"lower"`, `L"print"`, `L"punct"`, `L"space"`,
766
- `L"upper"` and `L"xdigit"` shall be recognized.
767
 
768
  ``` cpp
769
  bool isctype(charT c, char_class_type f) const;
770
  ```
771
 
772
  *Effects:* Determines if the character `c` is a member of the character
773
  classification represented by `f`.
774
 
775
- *Returns:* Converts `f` into a value `m` of type `std::ctype_base::mask`
776
- in an unspecified manner, and returns `true` if
777
- `use_facet<ctype<charT> >(getloc()).is(m, c)` is `true`. Otherwise
778
- returns `true` if `f` bitwise or’ed with the result of calling
779
- `lookup_classname` with an iterator pair that designates the character
780
- sequence `"w"` is not equal to 0 and `c == ’_’`, or if `f` bitwise or’ed
781
- with the result of calling `lookup_classname` with an iterator pair that
782
- designates the character sequence `"blank"` is not equal to 0 and `c` is
783
- one of an *implementation-defined* subset of the characters for which
784
- `isspace(c, getloc())` returns `true`, otherwise returns `false`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
785
 
786
  ``` cpp
787
  int value(charT ch, int radix) const;
788
  ```
789
 
@@ -813,10 +867,31 @@ locale_type getloc()const;
813
 
814
  *Returns:* if no locale has been imbued then a copy of the global locale
815
  in effect at the time of construction of `*this`, otherwise a copy of
816
  the last argument passed to `imbue`.
817
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
818
  ## Class template `basic_regex` <a id="re.regex">[[re.regex]]</a>
819
 
820
  For a char-like type `charT`, specializations of class template
821
  `basic_regex` represent regular expressions constructed from character
822
  sequences of `charT` characters. In the rest of  [[re.regex]], `charT`
@@ -959,11 +1034,11 @@ basic_regex();
959
 
960
  *Effects:* Constructs an object of class `basic_regex` that does not
961
  match any character sequence.
962
 
963
  ``` cpp
964
- basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript);
965
  ```
966
 
967
  *Requires:* *p* shall not be a null pointer.
968
 
969
  *Throws:* `regex_error` if *p* is not a valid regular expression.
@@ -1013,11 +1088,11 @@ basic_regex(basic_regex&& e) noexcept;
1013
  `e.flags()` and `e.mark_count()`, respectively, had before construction.
1014
  `e` is in a valid state with unspecified value.
1015
 
1016
  ``` cpp
1017
  template <class ST, class SA>
1018
- basic_regex(const basic_string<charT, ST, SA>& s,
1019
  flag_type f = regex_constants::ECMAScript);
1020
  ```
1021
 
1022
  *Throws:* `regex_error` if `s` is not a valid regular expression.
1023
 
@@ -1202,11 +1277,11 @@ void swap(basic_regex& e);
1202
  *Effects:* Swaps the contents of the two regular expressions.
1203
 
1204
  `*this` contains the regular expression that was in `e`, `e` contains
1205
  the regular expression that was in `*this`.
1206
 
1207
- *Complexity:* constant time.
1208
 
1209
  ### `basic_regex` non-member functions <a id="re.regex.nonmemb">[[re.regex.nonmemb]]</a>
1210
 
1211
  #### `basic_regex` non-member swap <a id="re.regex.nmswap">[[re.regex.nmswap]]</a>
1212
 
@@ -1687,16 +1762,16 @@ formed that match. Otherwise `matched` is false, and members `first` and
1687
  participate in a regular expression match need not be distinct.
1688
 
1689
  ``` cpp
1690
  namespace std {
1691
  template <class BidirectionalIterator,
1692
- class Allocator = allocator<sub_match<BidirectionalIterator> >
1693
  class match_results {
1694
  public:
1695
  typedef sub_match<BidirectionalIterator> value_type;
1696
  typedef const value_type& const_reference;
1697
- typedef const_reference reference;
1698
  typedef {implementation-defined} const_iterator;
1699
  typedef const_iterator iterator;
1700
  typedef typename
1701
  iterator_traits<BidirectionalIterator>::difference_type difference_type;
1702
  typedef typename allocator_traits<Allocator>::size_type size_type;
@@ -1794,11 +1869,11 @@ match_results(match_results&& m) noexcept;
1794
  *Effects:*  Move-constructs an object of class `match_results` from `m`
1795
  satisfying the same postconditions as Table  [[tab:re:results:assign]].
1796
  Additionally, the stored `Allocator` value is move constructed from
1797
  `m.get_allocator()`.
1798
 
1799
- *Throws:* Nothing if the allocator’s move constructor throws nothing.
1800
 
1801
  ``` cpp
1802
  match_results& operator=(const match_results& m);
1803
  ```
1804
 
@@ -2022,11 +2097,11 @@ void swap(match_results& that);
2022
 
2023
  `*this` contains the sequence of matched sub-expressions that were in
2024
  `that`, `that` contains the sequence of matched sub-expressions that
2025
  were in `*this`.
2026
 
2027
- *Complexity:* constant time.
2028
 
2029
  ``` cpp
2030
  template <class BidirectionalIterator, class Allocator>
2031
  void swap(match_results<BidirectionalIterator, Allocator>& m1,
2032
  match_results<BidirectionalIterator, Allocator>& m2);
@@ -2100,25 +2175,25 @@ that `m.size()` returns `0` and `m.empty()` returns `true`. Otherwise
2100
  the effects on parameter `m` are given in Table  [[tab:re:alg:match]].
2101
 
2102
  **Table: Effects of `regex_match` algorithm** <a id="tab:re:alg:match">[tab:re:alg:match]</a>
2103
 
2104
  | Element | Value |
2105
- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
2106
  | `m.size()` | `1 + e.mark_count()` |
2107
  | `m.empty()` | false |
2108
  | `m.prefix().first` | first |
2109
  | `m.prefix().second` | first |
2110
  | `m.prefix().matched` | false |
2111
  | `m.suffix().first` | last |
2112
  | `m.suffix().second` | last |
2113
  | `m.suffix().matched` | false |
2114
  | `m[0].first` | first |
2115
  | `m[0].second` | last |
2116
- | `m[0].matched` | `true` if a full match was found. |
2117
- | `m[n].first` | For all integers `n < m.size()`, the start of the sequence that matched sub-expression `n`. Alternatively, if sub-expression `n` did not participate in the match, then `last`. |
2118
- | `m[n].second` | For all integers `n < m.size()`, the end of the sequence that matched sub-expression `n`. Alternatively, if sub-expression `n` did not participate in the match, then `last`. |
2119
- | `m[n].matched` | For all integers `n < m.size()`, `true` if sub-expression `n` participated in the match, `false` otherwise. |
2120
 
2121
  ``` cpp
2122
  template <class BidirectionalIterator, class charT, class traits>
2123
  bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
2124
  const basic_regex<charT, traits>& e,
@@ -2202,25 +2277,25 @@ that `m.size()` returns `0` and `m.empty()` returns `true`. Otherwise
2202
  the effects on parameter `m` are given in Table  [[tab:re:alg:search]].
2203
 
2204
  **Table: Effects of `regex_search` algorithm** <a id="tab:re:alg:search">[tab:re:alg:search]</a>
2205
 
2206
  | Element | Value |
2207
- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
2208
  | `m.size()` | `1 + e.mark_count()` |
2209
  | `m.empty()` | `false` |
2210
  | `m.prefix().first` | `first` |
2211
  | `m.prefix().second` | `m[0].first` |
2212
  | `m.prefix().matched` | `m.prefix().first != m.prefix().second` |
2213
  | `m.suffix().first` | `m[0].second` |
2214
  | `m.suffix().second` | `last` |
2215
  | `m.suffix().matched` | `m.suffix().first != m.suffix().second` |
2216
  | `m[0].first` | The start of the sequence of characters that matched the regular expression |
2217
  | `m[0].second` | The end of the sequence of characters that matched the regular expression |
2218
- | `m[0].matched` | `true` if a match was found, and `false` otherwise. |
2219
- | `m[n].first` | For all integers `n < m.size()`, the start of the sequence that matched sub-expression `n`. Alternatively, if sub-expression `n` did not participate in the match, then `last`. |
2220
- | `m[n].second` | For all integers `n < m.size()`, the end of the sequence that matched sub-expression `n`. Alternatively, if sub-expression `n` did not participate in the match, then `last` . |
2221
- | `m[n].matched` | For all integers `n < m.size()`, `true` if sub-expression `n` participated in the match, `false` otherwise. |
2222
 
2223
  ``` cpp
2224
  template <class charT, class Allocator, class traits>
2225
  bool regex_search(const charT* str, match_results<const charT*, Allocator>& m,
2226
  const basic_regex<charT, traits>& e,
@@ -2300,26 +2375,50 @@ template <class OutputIterator, class BidirectionalIterator,
2300
  regex_constants::match_flag_type flags =
2301
  regex_constants::match_default);
2302
  ```
2303
 
2304
  *Effects:* Constructs a `regex_iterator` object `i` as if by
2305
- `regex_iterator<BidirectionalIterator, charT, traits> i(first, last, e, flags)`,
 
 
 
 
2306
  and uses `i` to enumerate through all of the matches `m` of type
2307
  `match_results<BidirectionalIterator>` that occur within the sequence
2308
  \[`first`, `last`). If no such matches are found and
2309
- `!(flags & regex_constants ``format_no_copy)` then calls
2310
- `std::copy(first, last, out)`. If any matches are found then, for each
2311
- such match, if `!(flags & regex_constants::format_no_copy)`, calls
2312
- `std::copy(m.prefix().first, m.prefix().second, out)`, and then calls
2313
- `m.format(out, fmt, flags)` for the first form of the function and
2314
- `m.format(out,` `fmt, fmt + char_traits<charT>::length(fmt), flags)` for
2315
- the second.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2316
 
2317
  Finally, if such a match is found and
2318
- `!(flags & regex_constants ``format_no_copy)`, calls
2319
- `std::copy(last_m.suffix().first, last_m.suffix().second, out)` where
2320
- `last_m` is a copy of the last match found. If
 
 
 
 
2321
  `flags & regex_constants::format_first_only` is non-zero then only the
2322
  first match found is replaced.
2323
 
2324
  *Returns:* `out`.
2325
 
@@ -2346,11 +2445,11 @@ template <class traits, class charT, class ST, class SA>
2346
 
2347
  *Returns:*  `result`.
2348
 
2349
  ``` cpp
2350
  template <class traits, class charT, class ST, class SA>
2351
- basic_string<charT>}
2352
  regex_replace(const charT* s,
2353
  const basic_regex<charT, traits>& e,
2354
  const basic_string<charT, ST, SA>& fmt,
2355
  regex_constants::match_flag_type flags =
2356
  regex_constants::match_default);
@@ -2412,25 +2511,28 @@ namespace std {
2412
  regex_iterator();
2413
  regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
2414
  const regex_type& re,
2415
  regex_constants::match_flag_type m =
2416
  regex_constants::match_default);
 
 
 
 
2417
  regex_iterator(const regex_iterator&);
2418
  regex_iterator& operator=(const regex_iterator&);
2419
  bool operator==(const regex_iterator&) const;
2420
  bool operator!=(const regex_iterator&) const;
2421
  const value_type& operator*() const;
2422
  const value_type* operator->() const;
2423
  regex_iterator& operator++();
2424
  regex_iterator operator++(int);
2425
  private:
2426
- // these members are shown for exposition only:
2427
- BidirectionalIterator begin;
2428
- BidirectionalIterator end;
2429
- const regex_type* pregex;
2430
- regex_constants::match_flag_type flags;
2431
- match_results<BidirectionalIterator> match;
2432
  };
2433
  }
2434
  ```
2435
 
2436
  An object of type `regex_iterator` that is not an end-of-sequence
@@ -2479,11 +2581,11 @@ otherwise `false`.
2479
  bool operator!=(const regex_iterator& right) const;
2480
  ```
2481
 
2482
  *Returns:* `!(*this == right)`.
2483
 
2484
- #### `regex_iterator` dereference <a id="re.regiter.deref">[[re.regiter.deref]]</a>
2485
 
2486
  ``` cpp
2487
  const value_type& operator*() const;
2488
  ```
2489
 
@@ -2629,25 +2731,47 @@ namespace std {
2629
  regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
2630
  const regex_type& re,
2631
  const int (&submatches)[N],
2632
  regex_constants::match_flag_type m =
2633
  regex_constants::match_default);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2634
  regex_token_iterator(const regex_token_iterator&);
2635
  regex_token_iterator& operator=(const regex_token_iterator&);
2636
  bool operator==(const regex_token_iterator&) const;
2637
  bool operator!=(const regex_token_iterator&) const;
2638
  const value_type& operator*() const;
2639
  const value_type* operator->() const;
2640
  regex_token_iterator& operator++();
2641
  regex_token_iterator operator++(int);
2642
- private: // data members for exposition only:
2643
- typedef regex_iterator<BidirectionalIterator, charT, traits> position_iterator;
2644
- position_iterator position;
2645
- const value_type *result;
2646
- value_type suffix;
2647
- std::size_t N;
2648
- std::vector<int> subs;
 
2649
  };
2650
  }
2651
  ```
2652
 
2653
  A *suffix iterator* is a `regex_token_iterator` object that points to a
@@ -2735,11 +2859,11 @@ returns `true` if `position == right.position`, `N == right.N`, and
2735
  bool operator!=(const regex_token_iterator& right) const;
2736
  ```
2737
 
2738
  *Returns:* `!(*this == right)`.
2739
 
2740
- #### `regex_token_iterator` dereference <a id="re.tokiter.deref">[[re.tokiter.deref]]</a>
2741
 
2742
  ``` cpp
2743
  const value_type& operator*() const;
2744
  ```
2745
 
@@ -2945,10 +3069,11 @@ as follows:
2945
  <!-- Link reference definitions -->
2946
  [algorithms]: algorithms.md#algorithms
2947
  [bidirectional.iterators]: iterators.md#bidirectional.iterators
2948
  [bitmask.types]: library.md#bitmask.types
2949
  [enumerated.types]: library.md#enumerated.types
 
2950
  [input.iterators]: iterators.md#input.iterators
2951
  [output.iterators]: iterators.md#output.iterators
2952
  [re]: #re
2953
  [re.alg]: #re.alg
2954
  [re.alg.match]: #re.alg.match
@@ -2998,10 +3123,11 @@ as follows:
2998
  [re.tokiter.deref]: #re.tokiter.deref
2999
  [re.tokiter.incr]: #re.tokiter.incr
3000
  [re.traits]: #re.traits
3001
  [sequence.reqmts]: containers.md#sequence.reqmts
3002
  [tab:re.lib.summary]: #tab:re.lib.summary
 
3003
  [tab:re:RegexpTraits]: #tab:re:RegexpTraits
3004
  [tab:re:alg:match]: #tab:re:alg:match
3005
  [tab:re:alg:search]: #tab:re:alg:search
3006
  [tab:re:errortype]: #tab:re:errortype
3007
  [tab:re:matchflag]: #tab:re:matchflag
 
79
 
80
  The class template `basic_regex`, defined in Clause  [[re.regex]], needs
81
  a set of related types and functions to complete the definition of its
82
  semantics. These types and functions are provided as a set of member
83
  typedefs and functions in the template parameter `traits` used by the
84
+ `basic_regex` class template. This subclause defines the semantics of
85
+ these members.
86
 
87
  To specialize class template `basic_regex` for a character container
88
  `CharT` and its related regular expression traits class `Traits`, use
89
  `basic_regex<CharT, Traits>`.
90
 
91
  In Table  [[tab:re:RegexpTraits]] `X` denotes a traits class defining
92
  types and functions for the character container type `charT`; `u` is an
93
  object of type `X`; `v` is an object of type `const
94
+ X`; `p` is a value of type `const charT*`; `I1` and `I2` are input
95
+ iterators ([[input.iterators]]); `F1` and `F2` are forward iterators (
96
+ [[forward.iterators]]); `c` is a value of type `const charT`; `s` is an
97
+ object of type `X::string_type`; `cs` is an object of type
98
+ `const X::string_type`; `b` is a value of type `bool`; `I` is a value of
99
+ type `int`; `cl` is an object of type `X::char_class_type`, and `loc` is
100
+ an object of type `X::locale_type`.
101
 
102
  Class template `regex_traits` satisfies the requirements for a regular
103
  expression traits class when it is specialized for `char` or `wchar_t`.
104
+ This class template is described in the header `<regex>`, and is
105
  described in Clause  [[re.traits]].
106
 
107
  ## Header `<regex>` synopsis <a id="re.syn">[[re.syn]]</a>
108
 
109
  ``` cpp
 
345
  typename basic_string<charT, ST, SA>::const_iterator,
346
  Allocator>& m,
347
  const basic_regex<charT, traits>& e,
348
  regex_constants::match_flag_type flags =
349
  regex_constants::match_default);
350
+ template <class ST, class SA, class Allocator, class charT, class traits>
351
+ bool regex_match(const basic_string<charT, ST, SA>&&,
352
+ match_results<
353
+ typename basic_string<charT, ST, SA>::const_iterator,
354
+ Allocator>&,
355
+ const basic_regex<charT, traits>&,
356
+ regex_constants::match_flag_type =
357
+ regex_constants::match_default) = delete;
358
  template <class charT, class traits>
359
  bool regex_match(const charT* str,
360
  const basic_regex<charT, traits>& e,
361
  regex_constants::match_flag_type flags =
362
  regex_constants::match_default);
 
401
  typename basic_string<charT, ST, SA>::const_iterator,
402
  Allocator>& m,
403
  const basic_regex<charT, traits>& e,
404
  regex_constants::match_flag_type flags =
405
  regex_constants::match_default);
406
+ template <class ST, class SA, class Allocator, class charT, class traits>
407
+ bool regex_search(const basic_string<charT, ST, SA>&&,
408
+ match_results<
409
+ typename basic_string<charT, ST, SA>::const_iterator,
410
+ Allocator>&,
411
+ const basic_regex<charT, traits>&,
412
+ regex_constants::match_flag_type =
413
+ regex_constants::match_default) = delete;
414
 
415
  // [re.alg.replace], function template regex_replace:
416
  template <class OutputIterator, class BidirectionalIterator,
417
  class traits, class charT, class ST, class SA>
418
  OutputIterator
 
498
 
499
  ``` cpp
500
  namespace std {
501
  namespace regex_constants {
502
  typedef T1 syntax_option_type;
503
+ constexpr syntax_option_type icase = unspecified;
504
+ constexpr syntax_option_type nosubs = unspecified;
505
+ constexpr syntax_option_type optimize = unspecified;
506
+ constexpr syntax_option_type collate = unspecified;
507
+ constexpr syntax_option_type ECMAScript = unspecified;
508
+ constexpr syntax_option_type basic = unspecified;
509
+ constexpr syntax_option_type extended = unspecified;
510
+ constexpr syntax_option_type awk = unspecified;
511
+ constexpr syntax_option_type grep = unspecified;
512
+ constexpr syntax_option_type egrep = unspecified;
513
  }
514
  }
515
  ```
516
 
517
  The type `syntax_option_type` is an implementation-defined bitmask
518
  type ([[bitmask.types]]). Setting its elements has the effects listed
519
  in table  [[tab:re:syntaxoption]]. A valid value of type
520
+ `syntax_option_type` shall have at most one of the grammar elements
521
+ `ECMAScript`, `basic`, `extended`, `awk`, `grep`, `egrep`, set. If no
522
+ grammar element is set, the default grammar is `ECMAScript`.
523
 
524
  **Table: `syntax_option_type` effects** <a id="tab:re:syntaxoption">[tab:re:syntaxoption]</a>
525
 
526
  | Element | Effect(s) if set |
527
+ | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
528
+ | % `icase` | Specifies that matching of regular expressions against a character container sequence shall be performed without regard to case. \indexlibrary{\idxcode{syntax_option_type}!\idxcode{icase}}% |
529
+ | % `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` structure. \indexlibrary{\idxcode{syntax_option_type}!\idxcode{nosubs}}% |
530
+ | % `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. \indexlibrary{\idxcode{syntax_option_type}!\idxcode{optimize}}% |
531
+ | % `collate` | Specifies that character ranges of the form `"[a-b]"` shall be locale sensitive. \indexlibrary{\idxcode{syntax_option_type}!\idxcode{collate}}% \indextext{locale}% |
532
+ | % `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]]. \indextext{ECMAScript}% \indexlibrary{\idxcode{syntax_option_type}!\idxcode{ECMAScript}}% |
533
+ | % `basic` | Specifies that the grammar recognized by the regular expression engine shall be that used by basic regular expressions in POSIX, Base Definitions and Headers, Section 9, Regular Expressions. \indextext{POSIX!regular expressions}% \indexlibrary{\idxcode{syntax_option_type}!\idxcode{basic}}% |
534
+ | % `extended` | Specifies that the grammar recognized by the regular expression engine shall be that used by extended regular expressions in POSIX, Base Definitions and Headers, Section 9, Regular Expressions. \indextext{POSIX!extended regular expressions}% \indexlibrary{\idxcode{syntax_option_type}!\idxcode{extended}}% |
535
+ | % `awk` | Specifies that the grammar recognized by the regular expression engine shall be that used by the utility awk in POSIX. \indextext{\idxcode{awk}}% \indexlibrary{\idxcode{syntax_option_type}!\idxcode{awk}}% |
536
+ | % `grep` | Specifies that the grammar recognized by the regular expression engine shall be that used by the utility grep in POSIX. \indextext{\idxcode{grep}}% \indexlibrary{\idxcode{syntax_option_type}!\idxcode{grep}}% |
537
+ | % `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}}% \indexlibrary{\idxcode{syntax_option_type}!\idxcode{egrep}}% |
538
 
539
 
540
  ### Bitmask type `regex_constants::match_flag_type` <a id="re.matchflag">[[re.matchflag]]</a>
541
 
542
  ``` cpp
543
  namespace std {
544
  namespace regex_constants{
545
  typedef T2 match_flag_type;
546
+ constexpr match_flag_type match_default = {};
547
+ constexpr match_flag_type match_not_bol = unspecified;
548
+ constexpr match_flag_type match_not_eol = unspecified;
549
+ constexpr match_flag_type match_not_bow = unspecified;
550
+ constexpr match_flag_type match_not_eow = unspecified;
551
+ constexpr match_flag_type match_any = unspecified;
552
+ constexpr match_flag_type match_not_null = unspecified;
553
+ constexpr match_flag_type match_continuous = unspecified;
554
+ constexpr match_flag_type match_prev_avail = unspecified;
555
+ constexpr match_flag_type format_default = {};
556
+ constexpr match_flag_type format_sed = unspecified;
557
+ constexpr match_flag_type format_no_copy = unspecified;
558
+ constexpr match_flag_type format_first_only = unspecified;
559
  }
560
  }
561
  ```
562
 
563
  The type `regex_constants::match_flag_type` is an implementation-defined
564
+ bitmask type ([[bitmask.types]]). The constants of that type, except
565
+ for `match_default` and `format_default`, are bitmask elements. The
566
+ `match_default` and `format_default` constants are empty bitmasks.
567
+ Matching a regular expression against a sequence of characters
568
+ \[`first`, `last`) proceeds according to the rules of the grammar
569
+ specified for the regular expression object, modified according to the
570
+ effects listed in Table  [[tab:re:matchflag]] for any bitmask elements
571
+ set.
572
 
573
  **Table: `regex_constants::match_flag_type` effects when obtaining a match against a
574
  character container sequence {[}`first`, `last`{)}.** <a id="tab:re:matchflag">[tab:re:matchflag]</a>
575
 
576
  | Element | Effect(s) if set |
577
+ | ----------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
578
+ | % \indexlibrary{\idxcode{match_not_bol}}% `match_not_bol` | The first character in the sequence {[}`first`, `last`{)} shall be treated as though it is not at the beginning of a line, so the character \verb|^| in the regular expression shall not match {[}`first`, `first`{)}. |
579
+ | % \indexlibrary{\idxcode{match_not_eol}}% `match_not_eol` | The last character in the sequence {[}`first`, `last`{)} shall be treated as though it is not at the end of a line, so the character \verb|"$"| in the regular expression shall not match {[}`last`, `last`{)}. |
580
+ | % \indexlibrary{\idxcode{match_not_bow}}% `match_not_bow` | The expression \verb|"b"| shall not match the sub-sequence {[}`first`, `first`{)}. |
581
+ | % \indexlibrary{\idxcode{match_not_eow}}% `match_not_eow` | The expression \verb|"b"| shall not match the sub-sequence {[}`last`, `last`{)}. |
582
+ | % \indexlibrary{\idxcode{match_any}}% `match_any` | If more than one match is possible then any match is an acceptable result. |
583
+ | % \indexlibrary{\idxcode{match_not_null}}% `match_not_null` | The expression shall not match an empty sequence. |
584
+ | % \indexlibrary{\idxcode{match_continuous}}% `match_continuous` | The expression shall only match a sub-sequence that begins at `first`. |
585
+ | % \indexlibrary{\idxcode{match_prev_avail}}% `match_prev_avail` | \verb!--first! is a valid iterator position. When this flag is set the flags match_not_bol and match_not_bow shall be ignored by the regular expression algorithms~ [[re.alg]] and iterators~ [[re.iter]]. |
586
+ | % \indexlibrary{\idxcode{format_default}}% `format_default` | When a regular expression match is to be replaced by a new string, the new string shall be constructed using the rules used by the ECMAScript replace function in ECMA-262, part 15.5.4.11 String.prototype.replace. In addition, during search and replace operations all non-overlapping occurrences of the regular expression shall be located and replaced, and sections of the input that did not match the expression shall be copied unchanged to the output string. |
587
+ | % \indexlibrary{\idxcode{format_sed}}% `format_sed` | When a regular expression match is to be replaced by a new string, the new string shall be constructed using the rules used by the sed utility in POSIX. |
588
+ | % \indexlibrary{\idxcode{format_no_copy}}% `format_no_copy` | During a search and replace operation, sections of the character container sequence being searched that do not match the regular expression shall not be copied to the output string. |
589
+ | % \indexlibrary{\idxcode{format_first_only}}% `format_first_only` | When specified during a search and replace operation, only the first occurrence of the regular expression shall be replaced. |
590
 
591
 
592
  ### Implementation-defined `error_type` <a id="re.err">[[re.err]]</a>
593
 
594
  ``` cpp
595
  namespace std {
596
  namespace regex_constants {
597
  typedef T3 error_type;
598
+ constexpr error_type error_collate = unspecified;
599
+ constexpr error_type error_ctype = unspecified;
600
+ constexpr error_type error_escape = unspecified;
601
+ constexpr error_type error_backref = unspecified;
602
+ constexpr error_type error_brack = unspecified;
603
+ constexpr error_type error_paren = unspecified;
604
+ constexpr error_type error_brace = unspecified;
605
+ constexpr error_type error_badbrace = unspecified;
606
+ constexpr error_type error_range = unspecified;
607
+ constexpr error_type error_space = unspecified;
608
+ constexpr error_type error_badrepeat = unspecified;
609
+ constexpr error_type error_complexity = unspecified;
610
+ constexpr error_type error_stack = unspecified;
611
  }
612
  }
613
  ```
614
 
615
  The type `error_type` is an *implementation-defined* enumerated type (
 
773
  iterator range \[`first`, `last`). If the parameter `icase` is true then
774
  the returned mask identifies the character classification without regard
775
  to the case of the characters being matched, otherwise it does honor the
776
  case of the characters being matched.[^1] The value returned shall be
777
  independent of the case of the characters in the character sequence. If
778
+ the name is not recognized then returns `char_class_type()`.
 
779
 
780
+ *Remarks:* For `regex_traits<char>`, at least the narrow character names
781
+ in Table  [[tab:re.traits.classnames]] shall be recognized. For
782
+ `regex_traits<wchar_t>`, at least the wide character names in
783
+ Table  [[tab:re.traits.classnames]] shall be recognized.
 
 
 
784
 
785
  ``` cpp
786
  bool isctype(charT c, char_class_type f) const;
787
  ```
788
 
789
  *Effects:* Determines if the character `c` is a member of the character
790
  classification represented by `f`.
791
 
792
+ *Returns:* Given the following function prototype:
793
+
794
+ ``` cpp
795
+ // for exposition only
796
+ template<class C>
797
+ ctype_base::mask convert(typename regex_traits<C>::char_class_type f);
798
+ ```
799
+
800
+ that returns a value in which each `ctype_base::mask` value
801
+ corresponding to a value in `f` named in
802
+ Table  [[tab:re.traits.classnames]] is set, then the result is
803
+ determined as if by:
804
+
805
+ ``` cpp
806
+ ctype_base::mask m = convert<charT>(f);
807
+ const ctype<charT>& ct = use_facet<ctype<charT>>(getloc());
808
+ if (ct.is(m, c)) {
809
+ return true;
810
+ } else if (c == ct.widen('_')) {
811
+ charT w[1] = { ct.widen('w') };
812
+ char_class_type x = lookup_classname(w, w+1);
813
+
814
+ return (f&x) == x;
815
+ } else {
816
+ return false;
817
+ }
818
+ ```
819
+
820
+ ``` cpp
821
+ regex_traits<char> t;
822
+ string d("d");
823
+ string u("upper");
824
+ regex_traits<char>::char_class_type f;
825
+ f = t.lookup_classname(d.begin(), d.end());
826
+ f |= t.lookup_classname(u.begin(), u.end());
827
+ ctype_base::mask m = convert<char>(f); // m == ctype_base::digit|ctype_base::upper
828
+ ```
829
+
830
+ ``` cpp
831
+ regex_traits<char> t;
832
+ string w("w");
833
+ regex_traits<char>::char_class_type f;
834
+ f = t.lookup_classname(w.begin(), w.end());
835
+ t.isctype('A', f); // returns true
836
+ t.isctype('_', f); // returns true
837
+ t.isctype(' ', f); // returns false
838
+ ```
839
 
840
  ``` cpp
841
  int value(charT ch, int radix) const;
842
  ```
843
 
 
867
 
868
  *Returns:* if no locale has been imbued then a copy of the global locale
869
  in effect at the time of construction of `*this`, otherwise a copy of
870
  the last argument passed to `imbue`.
871
 
872
+ **Table: Character class names and corresponding `ctype` masks** <a id="tab:re.traits.classnames">[tab:re.traits.classnames]</a>
873
+
874
+ | Narrow character name | Wide character name | Corresponding `ctype_base::mask` value |
875
+ | --------------------- | ------------------- | -------------------------------------- |
876
+ | `"alnum"` | `L"alnum"` | `ctype_base::alnum` |
877
+ | `"alpha"` | `L"alpha"` | `ctype_base::alpha` |
878
+ | `"blank"` | `L"blank"` | `ctype_base::blank` |
879
+ | `"cntrl"` | `L"cntrl"` | `ctype_base::cntrl` |
880
+ | `"digit"` | `L"digit"` | `ctype_base::digit` |
881
+ | `"d"` | `L"d"` | `ctype_base::digit` |
882
+ | `"graph"` | `L"graph"` | `ctype_base::graph` |
883
+ | `"lower"` | `L"lower"` | `ctype_base::lower` |
884
+ | `"print"` | `L"print"` | `ctype_base::print` |
885
+ | `"punct"` | `L"punct"` | `ctype_base::punct` |
886
+ | `"space"` | `L"space"` | `ctype_base::space` |
887
+ | `"s"` | `L"s"` | `ctype_base::space` |
888
+ | `"upper"` | `L"upper"` | `ctype_base::upper` |
889
+ | `"w"` | `L"w"` | `ctype_base::alnum` |
890
+ | `"xdigit"` | `L"xdigit"` | `ctype_base::xdigit` |
891
+
892
+
893
  ## Class template `basic_regex` <a id="re.regex">[[re.regex]]</a>
894
 
895
  For a char-like type `charT`, specializations of class template
896
  `basic_regex` represent regular expressions constructed from character
897
  sequences of `charT` characters. In the rest of  [[re.regex]], `charT`
 
1034
 
1035
  *Effects:* Constructs an object of class `basic_regex` that does not
1036
  match any character sequence.
1037
 
1038
  ``` cpp
1039
+ explicit basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript);
1040
  ```
1041
 
1042
  *Requires:* *p* shall not be a null pointer.
1043
 
1044
  *Throws:* `regex_error` if *p* is not a valid regular expression.
 
1088
  `e.flags()` and `e.mark_count()`, respectively, had before construction.
1089
  `e` is in a valid state with unspecified value.
1090
 
1091
  ``` cpp
1092
  template <class ST, class SA>
1093
+ explicit basic_regex(const basic_string<charT, ST, SA>& s,
1094
  flag_type f = regex_constants::ECMAScript);
1095
  ```
1096
 
1097
  *Throws:* `regex_error` if `s` is not a valid regular expression.
1098
 
 
1277
  *Effects:* Swaps the contents of the two regular expressions.
1278
 
1279
  `*this` contains the regular expression that was in `e`, `e` contains
1280
  the regular expression that was in `*this`.
1281
 
1282
+ *Complexity:* Constant time.
1283
 
1284
  ### `basic_regex` non-member functions <a id="re.regex.nonmemb">[[re.regex.nonmemb]]</a>
1285
 
1286
  #### `basic_regex` non-member swap <a id="re.regex.nmswap">[[re.regex.nmswap]]</a>
1287
 
 
1762
  participate in a regular expression match need not be distinct.
1763
 
1764
  ``` cpp
1765
  namespace std {
1766
  template <class BidirectionalIterator,
1767
+ class Allocator = allocator<sub_match<BidirectionalIterator>>>
1768
  class match_results {
1769
  public:
1770
  typedef sub_match<BidirectionalIterator> value_type;
1771
  typedef const value_type& const_reference;
1772
+ typedef value_type& reference;
1773
  typedef {implementation-defined} const_iterator;
1774
  typedef const_iterator iterator;
1775
  typedef typename
1776
  iterator_traits<BidirectionalIterator>::difference_type difference_type;
1777
  typedef typename allocator_traits<Allocator>::size_type size_type;
 
1869
  *Effects:*  Move-constructs an object of class `match_results` from `m`
1870
  satisfying the same postconditions as Table  [[tab:re:results:assign]].
1871
  Additionally, the stored `Allocator` value is move constructed from
1872
  `m.get_allocator()`.
1873
 
1874
+ *Throws:* Nothing.
1875
 
1876
  ``` cpp
1877
  match_results& operator=(const match_results& m);
1878
  ```
1879
 
 
2097
 
2098
  `*this` contains the sequence of matched sub-expressions that were in
2099
  `that`, `that` contains the sequence of matched sub-expressions that
2100
  were in `*this`.
2101
 
2102
+ *Complexity:* Constant time.
2103
 
2104
  ``` cpp
2105
  template <class BidirectionalIterator, class Allocator>
2106
  void swap(match_results<BidirectionalIterator, Allocator>& m1,
2107
  match_results<BidirectionalIterator, Allocator>& m2);
 
2175
  the effects on parameter `m` are given in Table  [[tab:re:alg:match]].
2176
 
2177
  **Table: Effects of `regex_match` algorithm** <a id="tab:re:alg:match">[tab:re:alg:match]</a>
2178
 
2179
  | Element | Value |
2180
+ | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
2181
  | `m.size()` | `1 + e.mark_count()` |
2182
  | `m.empty()` | false |
2183
  | `m.prefix().first` | first |
2184
  | `m.prefix().second` | first |
2185
  | `m.prefix().matched` | false |
2186
  | `m.suffix().first` | last |
2187
  | `m.suffix().second` | last |
2188
  | `m.suffix().matched` | false |
2189
  | `m[0].first` | first |
2190
  | `m[0].second` | last |
2191
+ | `m[0].matched` | `true` |
2192
+ | `m[n].first` | For all integers `0 < n < m.size()`, the start of the sequence that matched sub-expression `n`. Alternatively, if sub-expression `n` did not participate in the match, then `last`. |
2193
+ | `m[n].second` | For all integers `0 < n < m.size()`, the end of the sequence that matched sub-expression `n`. Alternatively, if sub-expression `n` did not participate in the match, then `last`. |
2194
+ | `m[n].matched` | For all integers `0 < n < m.size()`, `true` if sub-expression `n` participated in the match, `false` otherwise. |
2195
 
2196
  ``` cpp
2197
  template <class BidirectionalIterator, class charT, class traits>
2198
  bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
2199
  const basic_regex<charT, traits>& e,
 
2277
  the effects on parameter `m` are given in Table  [[tab:re:alg:search]].
2278
 
2279
  **Table: Effects of `regex_search` algorithm** <a id="tab:re:alg:search">[tab:re:alg:search]</a>
2280
 
2281
  | Element | Value |
2282
+ | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
2283
  | `m.size()` | `1 + e.mark_count()` |
2284
  | `m.empty()` | `false` |
2285
  | `m.prefix().first` | `first` |
2286
  | `m.prefix().second` | `m[0].first` |
2287
  | `m.prefix().matched` | `m.prefix().first != m.prefix().second` |
2288
  | `m.suffix().first` | `m[0].second` |
2289
  | `m.suffix().second` | `last` |
2290
  | `m.suffix().matched` | `m.suffix().first != m.suffix().second` |
2291
  | `m[0].first` | The start of the sequence of characters that matched the regular expression |
2292
  | `m[0].second` | The end of the sequence of characters that matched the regular expression |
2293
+ | `m[0].matched` | `true` |
2294
+ | `m[n].first` | For all integers `0 < n < m.size()`, the start of the sequence that matched sub-expression `n`. Alternatively, if sub-expression `n` did not participate in the match, then `last`. |
2295
+ | `m[n].second` | For all integers `0 < n < m.size()`, the end of the sequence that matched sub-expression `n`. Alternatively, if sub-expression `n` did not participate in the match, then `last` . |
2296
+ | `m[n].matched` | For all integers `0 < n < m.size()`, `true` if sub-expression `n` participated in the match, `false` otherwise. |
2297
 
2298
  ``` cpp
2299
  template <class charT, class Allocator, class traits>
2300
  bool regex_search(const charT* str, match_results<const charT*, Allocator>& m,
2301
  const basic_regex<charT, traits>& e,
 
2375
  regex_constants::match_flag_type flags =
2376
  regex_constants::match_default);
2377
  ```
2378
 
2379
  *Effects:* Constructs a `regex_iterator` object `i` as if by
2380
+
2381
+ ``` cpp
2382
+ regex_iterator<BidirectionalIterator, charT, traits> i(first, last, e, flags)
2383
+ ```
2384
+
2385
  and uses `i` to enumerate through all of the matches `m` of type
2386
  `match_results<BidirectionalIterator>` that occur within the sequence
2387
  \[`first`, `last`). If no such matches are found and
2388
+ `!(flags & regex_constants::format_no_copy)` then calls
2389
+
2390
+ ``` cpp
2391
+ out = std::copy(first, last, out)
2392
+ ```
2393
+
2394
+ If any matches are found then, for each such match:
2395
+
2396
+ - If `!(flags & regex_constants::format_no_copy)`, calls
2397
+ ``` cpp
2398
+ out = std::copy(m.prefix().first, m.prefix().second, out)
2399
+ ```
2400
+ - Then calls
2401
+ ``` cpp
2402
+ out = m.format(out, fmt, flags)
2403
+ ```
2404
+
2405
+ for the first form of the function and
2406
+ ``` cpp
2407
+ out = m.format(out, fmt, fmt + char_traits<charT>::length(fmt), flags)
2408
+ ```
2409
+
2410
+ for the second.
2411
 
2412
  Finally, if such a match is found and
2413
+ `!(flags & regex_constants::format_no_copy)`, calls
2414
+
2415
+ ``` cpp
2416
+ out = std::copy(last_m.suffix().first, last_m.suffix().second, out)
2417
+ ```
2418
+
2419
+ where `last_m` is a copy of the last match found. If
2420
  `flags & regex_constants::format_first_only` is non-zero then only the
2421
  first match found is replaced.
2422
 
2423
  *Returns:* `out`.
2424
 
 
2445
 
2446
  *Returns:*  `result`.
2447
 
2448
  ``` cpp
2449
  template <class traits, class charT, class ST, class SA>
2450
+ basic_string<charT>
2451
  regex_replace(const charT* s,
2452
  const basic_regex<charT, traits>& e,
2453
  const basic_string<charT, ST, SA>& fmt,
2454
  regex_constants::match_flag_type flags =
2455
  regex_constants::match_default);
 
2511
  regex_iterator();
2512
  regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
2513
  const regex_type& re,
2514
  regex_constants::match_flag_type m =
2515
  regex_constants::match_default);
2516
+ regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
2517
+ const regex_type&& re,
2518
+ regex_constants::match_flag_type m =
2519
+ regex_constants::match_default) = delete;
2520
  regex_iterator(const regex_iterator&);
2521
  regex_iterator& operator=(const regex_iterator&);
2522
  bool operator==(const regex_iterator&) const;
2523
  bool operator!=(const regex_iterator&) const;
2524
  const value_type& operator*() const;
2525
  const value_type* operator->() const;
2526
  regex_iterator& operator++();
2527
  regex_iterator operator++(int);
2528
  private:
2529
+ BidirectionalIterator begin; // exposition only
2530
+ BidirectionalIterator end; // exposition only
2531
+ const regex_type* pregex; // exposition only
2532
+ regex_constants::match_flag_type flags; // exposition only
2533
+ match_results<BidirectionalIterator> match; // exposition only
 
2534
  };
2535
  }
2536
  ```
2537
 
2538
  An object of type `regex_iterator` that is not an end-of-sequence
 
2581
  bool operator!=(const regex_iterator& right) const;
2582
  ```
2583
 
2584
  *Returns:* `!(*this == right)`.
2585
 
2586
+ #### `regex_iterator` indirection <a id="re.regiter.deref">[[re.regiter.deref]]</a>
2587
 
2588
  ``` cpp
2589
  const value_type& operator*() const;
2590
  ```
2591
 
 
2731
  regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
2732
  const regex_type& re,
2733
  const int (&submatches)[N],
2734
  regex_constants::match_flag_type m =
2735
  regex_constants::match_default);
2736
+ regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
2737
+ const regex_type&& re,
2738
+ int submatch = 0,
2739
+ regex_constants::match_flag_type m =
2740
+ regex_constants::match_default) = delete;
2741
+ regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
2742
+ const regex_type&& re,
2743
+ const std::vector<int>& submatches,
2744
+ regex_constants::match_flag_type m =
2745
+ regex_constants::match_default) = delete;
2746
+ regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
2747
+ const regex_type&& re,
2748
+ initializer_list<int> submatches,
2749
+ regex_constants::match_flag_type m =
2750
+ regex_constants::match_default) = delete;
2751
+ template <std::size_t N>
2752
+ regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
2753
+ const regex_type&& re,
2754
+ const int (&submatches)[N],
2755
+ regex_constants::match_flag_type m =
2756
+ regex_constants::match_default) = delete;
2757
  regex_token_iterator(const regex_token_iterator&);
2758
  regex_token_iterator& operator=(const regex_token_iterator&);
2759
  bool operator==(const regex_token_iterator&) const;
2760
  bool operator!=(const regex_token_iterator&) const;
2761
  const value_type& operator*() const;
2762
  const value_type* operator->() const;
2763
  regex_token_iterator& operator++();
2764
  regex_token_iterator operator++(int);
2765
+ private:
2766
+ typedef
2767
+ regex_iterator<BidirectionalIterator, charT, traits> position_iterator; // exposition only
2768
+ position_iterator position; // exposition only
2769
+ const value_type* result; // exposition only
2770
+ value_type suffix; // exposition only
2771
+ std::size_t N; // exposition only
2772
+ std::vector<int> subs; // exposition only
2773
  };
2774
  }
2775
  ```
2776
 
2777
  A *suffix iterator* is a `regex_token_iterator` object that points to a
 
2859
  bool operator!=(const regex_token_iterator& right) const;
2860
  ```
2861
 
2862
  *Returns:* `!(*this == right)`.
2863
 
2864
+ #### `regex_token_iterator` indirection <a id="re.tokiter.deref">[[re.tokiter.deref]]</a>
2865
 
2866
  ``` cpp
2867
  const value_type& operator*() const;
2868
  ```
2869
 
 
3069
  <!-- Link reference definitions -->
3070
  [algorithms]: algorithms.md#algorithms
3071
  [bidirectional.iterators]: iterators.md#bidirectional.iterators
3072
  [bitmask.types]: library.md#bitmask.types
3073
  [enumerated.types]: library.md#enumerated.types
3074
+ [forward.iterators]: iterators.md#forward.iterators
3075
  [input.iterators]: iterators.md#input.iterators
3076
  [output.iterators]: iterators.md#output.iterators
3077
  [re]: #re
3078
  [re.alg]: #re.alg
3079
  [re.alg.match]: #re.alg.match
 
3123
  [re.tokiter.deref]: #re.tokiter.deref
3124
  [re.tokiter.incr]: #re.tokiter.incr
3125
  [re.traits]: #re.traits
3126
  [sequence.reqmts]: containers.md#sequence.reqmts
3127
  [tab:re.lib.summary]: #tab:re.lib.summary
3128
+ [tab:re.traits.classnames]: #tab:re.traits.classnames
3129
  [tab:re:RegexpTraits]: #tab:re:RegexpTraits
3130
  [tab:re:alg:match]: #tab:re:alg:match
3131
  [tab:re:alg:search]: #tab:re:alg:search
3132
  [tab:re:errortype]: #tab:re:errortype
3133
  [tab:re:matchflag]: #tab:re:matchflag