libstdc++
regex.h
Go to the documentation of this file.
1 // class template regex -*- C++ -*-
2 
3 // Copyright (C) 2010-2021 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
10 
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
19 
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
24 
25 /**
26  * @file bits/regex.h
27  * This is an internal header file, included by other library headers.
28  * Do not attempt to use it directly. @headername{regex}
29  */
30 
31 namespace std _GLIBCXX_VISIBILITY(default)
32 {
33 _GLIBCXX_BEGIN_NAMESPACE_VERSION
34 _GLIBCXX_BEGIN_NAMESPACE_CXX11
35  template<typename, typename>
36  class basic_regex;
37 
38  template<typename, typename>
39  class match_results;
40 
41 _GLIBCXX_END_NAMESPACE_CXX11
42 
43 namespace __detail
44 {
45  enum class _RegexExecutorPolicy : int { _S_auto, _S_alternate };
46 
47  template<typename _BiIter, typename _Alloc,
48  typename _CharT, typename _TraitsT,
49  _RegexExecutorPolicy __policy,
50  bool __match_mode>
51  bool
52  __regex_algo_impl(_BiIter __s,
53  _BiIter __e,
54  match_results<_BiIter, _Alloc>& __m,
55  const basic_regex<_CharT, _TraitsT>& __re,
57 
58  template<typename, typename, typename, bool>
59  class _Executor;
60 
61  template<typename _Tp>
62  struct __is_contiguous_iter : false_type { };
63 
64  template<typename _Tp>
65  struct __is_contiguous_iter<_Tp*> : true_type { };
66 
67  template<typename _Tp, typename _Cont>
68  struct __is_contiguous_iter<__gnu_cxx::__normal_iterator<_Tp*, _Cont>>
69  : true_type { };
70 }
71 
72 _GLIBCXX_BEGIN_NAMESPACE_CXX11
73 
74  /**
75  * @addtogroup regex
76  * @{
77  */
78 
79  /**
80  * @brief Describes aspects of a regular expression.
81  *
82  * A regular expression traits class that satisfies the requirements of
83  * section [28.7].
84  *
85  * The class %regex is parameterized around a set of related types and
86  * functions used to complete the definition of its semantics. This class
87  * satisfies the requirements of such a traits class.
88  */
89  template<typename _Ch_type>
91  {
92  public:
93  typedef _Ch_type char_type;
95  typedef std::locale locale_type;
96 
97  private:
98  struct _RegexMask
99  {
100  typedef std::ctype_base::mask _BaseType;
101  _BaseType _M_base;
102  unsigned char _M_extended;
103  static constexpr unsigned char _S_under = 1 << 0;
104  static constexpr unsigned char _S_valid_mask = 0x1;
105 
106  constexpr _RegexMask(_BaseType __base = 0,
107  unsigned char __extended = 0)
108  : _M_base(__base), _M_extended(__extended)
109  { }
110 
111  constexpr _RegexMask
112  operator&(_RegexMask __other) const
113  {
114  return _RegexMask(_M_base & __other._M_base,
115  _M_extended & __other._M_extended);
116  }
117 
118  constexpr _RegexMask
119  operator|(_RegexMask __other) const
120  {
121  return _RegexMask(_M_base | __other._M_base,
122  _M_extended | __other._M_extended);
123  }
124 
125  constexpr _RegexMask
126  operator^(_RegexMask __other) const
127  {
128  return _RegexMask(_M_base ^ __other._M_base,
129  _M_extended ^ __other._M_extended);
130  }
131 
132  constexpr _RegexMask
133  operator~() const
134  { return _RegexMask(~_M_base, ~_M_extended); }
135 
136  _RegexMask&
137  operator&=(_RegexMask __other)
138  { return *this = (*this) & __other; }
139 
140  _RegexMask&
141  operator|=(_RegexMask __other)
142  { return *this = (*this) | __other; }
143 
144  _RegexMask&
145  operator^=(_RegexMask __other)
146  { return *this = (*this) ^ __other; }
147 
148  constexpr bool
149  operator==(_RegexMask __other) const
150  {
151  return (_M_extended & _S_valid_mask)
152  == (__other._M_extended & _S_valid_mask)
153  && _M_base == __other._M_base;
154  }
155 
156 #if __cpp_impl_three_way_comparison < 201907L
157  constexpr bool
158  operator!=(_RegexMask __other) const
159  { return !((*this) == __other); }
160 #endif
161  };
162 
163  public:
164  typedef _RegexMask char_class_type;
165 
166  public:
167  /**
168  * @brief Constructs a default traits object.
169  */
171 
172  /**
173  * @brief Gives the length of a C-style string starting at @p __p.
174  *
175  * @param __p a pointer to the start of a character sequence.
176  *
177  * @returns the number of characters between @p *__p and the first
178  * default-initialized value of type @p char_type. In other words, uses
179  * the C-string algorithm for determining the length of a sequence of
180  * characters.
181  */
182  static std::size_t
183  length(const char_type* __p)
184  { return string_type::traits_type::length(__p); }
185 
186  /**
187  * @brief Performs the identity translation.
188  *
189  * @param __c A character to the locale-specific character set.
190  *
191  * @returns __c.
192  */
193  char_type
194  translate(char_type __c) const
195  { return __c; }
196 
197  /**
198  * @brief Translates a character into a case-insensitive equivalent.
199  *
200  * @param __c A character to the locale-specific character set.
201  *
202  * @returns the locale-specific lower-case equivalent of __c.
203  * @throws std::bad_cast if the imbued locale does not support the ctype
204  * facet.
205  */
206  char_type
207  translate_nocase(char_type __c) const
208  {
209  typedef std::ctype<char_type> __ctype_type;
210  const __ctype_type& __fctyp(use_facet<__ctype_type>(_M_locale));
211  return __fctyp.tolower(__c);
212  }
213 
214  /**
215  * @brief Gets a sort key for a character sequence.
216  *
217  * @param __first beginning of the character sequence.
218  * @param __last one-past-the-end of the character sequence.
219  *
220  * Returns a sort key for the character sequence designated by the
221  * iterator range [F1, F2) such that if the character sequence [G1, G2)
222  * sorts before the character sequence [H1, H2) then
223  * v.transform(G1, G2) < v.transform(H1, H2).
224  *
225  * What this really does is provide a more efficient way to compare a
226  * string to multiple other strings in locales with fancy collation
227  * rules and equivalence classes.
228  *
229  * @returns a locale-specific sort key equivalent to the input range.
230  *
231  * @throws std::bad_cast if the current locale does not have a collate
232  * facet.
233  */
234  template<typename _Fwd_iter>
235  string_type
236  transform(_Fwd_iter __first, _Fwd_iter __last) const
237  {
238  typedef std::collate<char_type> __collate_type;
239  const __collate_type& __fclt(use_facet<__collate_type>(_M_locale));
240  string_type __s(__first, __last);
241  return __fclt.transform(__s.data(), __s.data() + __s.size());
242  }
243 
244  /**
245  * @brief Gets a sort key for a character sequence, independent of case.
246  *
247  * @param __first beginning of the character sequence.
248  * @param __last one-past-the-end of the character sequence.
249  *
250  * Effects: if typeid(use_facet<collate<_Ch_type> >) ==
251  * typeid(collate_byname<_Ch_type>) and the form of the sort key
252  * returned by collate_byname<_Ch_type>::transform(__first, __last)
253  * is known and can be converted into a primary sort key
254  * then returns that key, otherwise returns an empty string.
255  *
256  * @todo Implement this function correctly.
257  */
258  template<typename _Fwd_iter>
259  string_type
260  transform_primary(_Fwd_iter __first, _Fwd_iter __last) const
261  {
262  // TODO : this is not entirely correct.
263  // This function requires extra support from the platform.
264  //
265  // Read http://gcc.gnu.org/ml/libstdc++/2013-09/msg00117.html and
266  // http://www.open-std.org/Jtc1/sc22/wg21/docs/papers/2003/n1429.htm
267  // for details.
268  typedef std::ctype<char_type> __ctype_type;
269  const __ctype_type& __fctyp(use_facet<__ctype_type>(_M_locale));
270  _GLIBCXX_STD_C::vector<char_type> __s(__first, __last);
271  __fctyp.tolower(__s.data(), __s.data() + __s.size());
272  return this->transform(__s.data(), __s.data() + __s.size());
273  }
274 
275  /**
276  * @brief Gets a collation element by name.
277  *
278  * @param __first beginning of the collation element name.
279  * @param __last one-past-the-end of the collation element name.
280  *
281  * @returns a sequence of one or more characters that represents the
282  * collating element consisting of the character sequence designated by
283  * the iterator range [__first, __last). Returns an empty string if the
284  * character sequence is not a valid collating element.
285  */
286  template<typename _Fwd_iter>
287  string_type
288  lookup_collatename(_Fwd_iter __first, _Fwd_iter __last) const;
289 
290  /**
291  * @brief Maps one or more characters to a named character
292  * classification.
293  *
294  * @param __first beginning of the character sequence.
295  * @param __last one-past-the-end of the character sequence.
296  * @param __icase ignores the case of the classification name.
297  *
298  * @returns an unspecified value that represents the character
299  * classification named by the character sequence designated by
300  * the iterator range [__first, __last). If @p icase is true,
301  * the returned mask identifies the classification regardless of
302  * the case of the characters to be matched (for example,
303  * [[:lower:]] is the same as [[:alpha:]]), otherwise a
304  * case-dependent classification is returned. The value
305  * returned shall be independent of the case of the characters
306  * in the character sequence. If the name is not recognized then
307  * returns a value that compares equal to 0.
308  *
309  * At least the following names (or their wide-character equivalent) are
310  * supported.
311  * - d
312  * - w
313  * - s
314  * - alnum
315  * - alpha
316  * - blank
317  * - cntrl
318  * - digit
319  * - graph
320  * - lower
321  * - print
322  * - punct
323  * - space
324  * - upper
325  * - xdigit
326  */
327  template<typename _Fwd_iter>
328  char_class_type
329  lookup_classname(_Fwd_iter __first, _Fwd_iter __last,
330  bool __icase = false) const;
331 
332  /**
333  * @brief Determines if @p c is a member of an identified class.
334  *
335  * @param __c a character.
336  * @param __f a class type (as returned from lookup_classname).
337  *
338  * @returns true if the character @p __c is a member of the classification
339  * represented by @p __f, false otherwise.
340  *
341  * @throws std::bad_cast if the current locale does not have a ctype
342  * facet.
343  */
344  bool
345  isctype(_Ch_type __c, char_class_type __f) const;
346 
347  /**
348  * @brief Converts a digit to an int.
349  *
350  * @param __ch a character representing a digit.
351  * @param __radix the radix if the numeric conversion (limited to 8, 10,
352  * or 16).
353  *
354  * @returns the value represented by the digit __ch in base radix if the
355  * character __ch is a valid digit in base radix; otherwise returns -1.
356  */
357  int
358  value(_Ch_type __ch, int __radix) const;
359 
360  /**
361  * @brief Imbues the regex_traits object with a copy of a new locale.
362  *
363  * @param __loc A locale.
364  *
365  * @returns a copy of the previous locale in use by the regex_traits
366  * object.
367  *
368  * @note Calling imbue with a different locale than the one currently in
369  * use invalidates all cached data held by *this.
370  */
373  {
374  std::swap(_M_locale, __loc);
375  return __loc;
376  }
377 
378  /**
379  * @brief Gets a copy of the current locale in use by the regex_traits
380  * object.
381  */
382  locale_type
383  getloc() const
384  { return _M_locale; }
385 
386  protected:
387  locale_type _M_locale;
388  };
389 
390  // [7.8] Class basic_regex
391  /**
392  * Objects of specializations of this class represent regular expressions
393  * constructed from sequences of character type @p _Ch_type.
394  *
395  * Storage for the regular expression is allocated and deallocated as
396  * necessary by the member functions of this class.
397  */
398  template<typename _Ch_type, typename _Rx_traits = regex_traits<_Ch_type>>
400  {
401  public:
403  "regex traits class must have the same char_type");
404 
405  // types:
406  typedef _Ch_type value_type;
407  typedef _Rx_traits traits_type;
408  typedef typename traits_type::string_type string_type;
410  typedef typename traits_type::locale_type locale_type;
411 
412  /**
413  * @name Constants
414  * std [28.8.1](1)
415  */
416  ///@{
417  static constexpr flag_type icase = regex_constants::icase;
418  static constexpr flag_type nosubs = regex_constants::nosubs;
419  static constexpr flag_type optimize = regex_constants::optimize;
420  static constexpr flag_type collate = regex_constants::collate;
421  static constexpr flag_type ECMAScript = regex_constants::ECMAScript;
422  static constexpr flag_type basic = regex_constants::basic;
423  static constexpr flag_type extended = regex_constants::extended;
424  static constexpr flag_type awk = regex_constants::awk;
425  static constexpr flag_type grep = regex_constants::grep;
426  static constexpr flag_type egrep = regex_constants::egrep;
427 #if __cplusplus >= 201703L || !defined __STRICT_ANSI__
428  static constexpr flag_type multiline = regex_constants::multiline;
429 #endif
430  ///@}
431 
432  // [7.8.2] construct/copy/destroy
433  /**
434  * Constructs a basic regular expression that does not match any
435  * character sequence.
436  */
437  basic_regex() noexcept
438  : _M_flags(ECMAScript), _M_loc(), _M_automaton(nullptr)
439  { }
440 
441  /**
442  * @brief Constructs a basic regular expression from the
443  * sequence [__p, __p + char_traits<_Ch_type>::length(__p))
444  * interpreted according to the flags in @p __f.
445  *
446  * @param __p A pointer to the start of a C-style null-terminated string
447  * containing a regular expression.
448  * @param __f Flags indicating the syntax rules and options.
449  *
450  * @throws regex_error if @p __p is not a valid regular expression.
451  */
452  explicit
453  basic_regex(const _Ch_type* __p, flag_type __f = ECMAScript)
454  { _M_compile(__p, __p + _Rx_traits::length(__p), __f); }
455 
456  /**
457  * @brief Constructs a basic regular expression from the sequence
458  * [p, p + len) interpreted according to the flags in @p f.
459  *
460  * @param __p A pointer to the start of a string containing a regular
461  * expression.
462  * @param __len The length of the string containing the regular
463  * expression.
464  * @param __f Flags indicating the syntax rules and options.
465  *
466  * @throws regex_error if @p __p is not a valid regular expression.
467  */
468  basic_regex(const _Ch_type* __p, std::size_t __len,
469  flag_type __f = ECMAScript)
470  {
471  __glibcxx_requires_string_len(__p, __len);
472  _M_compile(__p, __p + __len, __f);
473  }
474 
475  /**
476  * @brief Copy-constructs a basic regular expression.
477  *
478  * @param __rhs A @p regex object.
479  */
480  basic_regex(const basic_regex& __rhs) = default;
481 
482  /**
483  * @brief Move-constructs a basic regular expression.
484  *
485  * @param __rhs A @p regex object.
486  */
487  basic_regex(basic_regex&& __rhs) noexcept = default;
488 
489  /**
490  * @brief Constructs a basic regular expression from the string
491  * @p s interpreted according to the flags in @p f.
492  *
493  * @param __s A string containing a regular expression.
494  * @param __f Flags indicating the syntax rules and options.
495  *
496  * @throws regex_error if @p __s is not a valid regular expression.
497  */
498  template<typename _Ch_traits, typename _Ch_alloc>
499  explicit
500  basic_regex(const std::basic_string<_Ch_type, _Ch_traits,
501  _Ch_alloc>& __s,
502  flag_type __f = ECMAScript)
503  { _M_compile(__s.data(), __s.data() + __s.size(), __f); }
504 
505  /**
506  * @brief Constructs a basic regular expression from the range
507  * [first, last) interpreted according to the flags in @p f.
508  *
509  * @param __first The start of a range containing a valid regular
510  * expression.
511  * @param __last The end of a range containing a valid regular
512  * expression.
513  * @param __f The format flags of the regular expression.
514  *
515  * @throws regex_error if @p [__first, __last) is not a valid regular
516  * expression.
517  */
518  template<typename _FwdIter>
519  basic_regex(_FwdIter __first, _FwdIter __last,
520  flag_type __f = ECMAScript)
521  { this->assign(__first, __last, __f); }
522 
523  /**
524  * @brief Constructs a basic regular expression from an initializer list.
525  *
526  * @param __l The initializer list.
527  * @param __f The format flags of the regular expression.
528  *
529  * @throws regex_error if @p __l is not a valid regular expression.
530  */
532  { _M_compile(__l.begin(), __l.end(), __f); }
533 
534  /**
535  * @brief Destroys a basic regular expression.
536  */
538  { }
539 
540  /**
541  * @brief Assigns one regular expression to another.
542  */
543  basic_regex&
544  operator=(const basic_regex&) = default;
545 
546  /**
547  * @brief Move-assigns one regular expression to another.
548  */
549  basic_regex&
550  operator=(basic_regex&&) = default;
551 
552  /**
553  * @brief Replaces a regular expression with a new one constructed from
554  * a C-style null-terminated string.
555  *
556  * @param __p A pointer to the start of a null-terminated C-style string
557  * containing a regular expression.
558  */
559  basic_regex&
560  operator=(const _Ch_type* __p)
561  { return this->assign(__p); }
562 
563  /**
564  * @brief Replaces a regular expression with a new one constructed from
565  * an initializer list.
566  *
567  * @param __l The initializer list.
568  *
569  * @throws regex_error if @p __l is not a valid regular expression.
570  */
571  basic_regex&
573  { return this->assign(__l); }
574 
575  /**
576  * @brief Replaces a regular expression with a new one constructed from
577  * a string.
578  *
579  * @param __s A pointer to a string containing a regular expression.
580  */
581  template<typename _Ch_traits, typename _Alloc>
582  basic_regex&
584  { return this->assign(__s); }
585 
586  // [7.8.3] assign
587  /**
588  * @brief Assigns one regular expression to another.
589  *
590  * @param __rhs Another regular expression object.
591  */
592  basic_regex&
593  assign(const basic_regex& __rhs) noexcept
594  { return *this = __rhs; }
595 
596  /**
597  * @brief Move-assigns one regular expression to another.
598  *
599  * @param __rhs Another regular expression object.
600  */
601  basic_regex&
602  assign(basic_regex&& __rhs) noexcept
603  { return *this = std::move(__rhs); }
604 
605  /**
606  * @brief Assigns a new regular expression to a regex object from a
607  * C-style null-terminated string containing a regular expression
608  * pattern.
609  *
610  * @param __p A pointer to a C-style null-terminated string containing
611  * a regular expression pattern.
612  * @param __flags Syntax option flags.
613  *
614  * @throws regex_error if __p does not contain a valid regular
615  * expression pattern interpreted according to @p __flags. If
616  * regex_error is thrown, *this remains unchanged.
617  */
618  basic_regex&
619  assign(const _Ch_type* __p, flag_type __flags = ECMAScript)
620  {
621  _M_compile(__p, __p + _Rx_traits::length(__p), __flags);
622  return *this;
623  }
624 
625  /**
626  * @brief Assigns a new regular expression to a regex object from a
627  * C-style string containing a regular expression pattern.
628  *
629  * @param __p A pointer to a C-style string containing a
630  * regular expression pattern.
631  * @param __len The length of the regular expression pattern string.
632  * @param __flags Syntax option flags.
633  *
634  * @throws regex_error if p does not contain a valid regular
635  * expression pattern interpreted according to @p __flags. If
636  * regex_error is thrown, *this remains unchanged.
637  */
638  // _GLIBCXX_RESOLVE_LIB_DEFECTS
639  // 3296. Inconsistent default argument for basic_regex<>::assign
640  basic_regex&
641  assign(const _Ch_type* __p, size_t __len, flag_type __flags = ECMAScript)
642  {
643  _M_compile(__p, __p + __len, __flags);
644  return *this;
645  }
646 
647  /**
648  * @brief Assigns a new regular expression to a regex object from a
649  * string containing a regular expression pattern.
650  *
651  * @param __s A string containing a regular expression pattern.
652  * @param __flags Syntax option flags.
653  *
654  * @throws regex_error if __s does not contain a valid regular
655  * expression pattern interpreted according to @p __flags. If
656  * regex_error is thrown, *this remains unchanged.
657  */
658  template<typename _Ch_traits, typename _Alloc>
659  basic_regex&
661  flag_type __flags = ECMAScript)
662  {
663  _M_compile(__s.data(), __s.data() + __s.size(), __flags);
664  return *this;
665  }
666 
667  /**
668  * @brief Assigns a new regular expression to a regex object.
669  *
670  * @param __first The start of a range containing a valid regular
671  * expression.
672  * @param __last The end of a range containing a valid regular
673  * expression.
674  * @param __flags Syntax option flags.
675  *
676  * @throws regex_error if p does not contain a valid regular
677  * expression pattern interpreted according to @p __flags. If
678  * regex_error is thrown, the object remains unchanged.
679  */
680  template<typename _InputIterator>
681  basic_regex&
682  assign(_InputIterator __first, _InputIterator __last,
683  flag_type __flags = ECMAScript)
684  {
685 #if __cpp_if_constexpr >= 201606L
686  using _ValT = typename iterator_traits<_InputIterator>::value_type;
687  if constexpr (__detail::__is_contiguous_iter<_InputIterator>::value
688  && is_same_v<_ValT, value_type>)
689  {
690  __glibcxx_requires_valid_range(__first, __last);
691  if constexpr (is_pointer_v<_InputIterator>)
692  _M_compile(__first, __last, __flags);
693  else // __normal_iterator<_T*, C>
694  _M_compile(__first.base(), __last.base(), __flags);
695  }
696  else
697 #endif
698  this->assign(string_type(__first, __last), __flags);
699  return *this;
700  }
701 
702  /**
703  * @brief Assigns a new regular expression to a regex object.
704  *
705  * @param __l An initializer list representing a regular expression.
706  * @param __flags Syntax option flags.
707  *
708  * @throws regex_error if @p __l does not contain a valid
709  * regular expression pattern interpreted according to @p
710  * __flags. If regex_error is thrown, the object remains
711  * unchanged.
712  */
713  basic_regex&
714  assign(initializer_list<_Ch_type> __l, flag_type __flags = ECMAScript)
715  {
716  _M_compile(__l.begin(), __l.end(), __flags);
717  return *this;
718  }
719 
720  // [7.8.4] const operations
721  /**
722  * @brief Gets the number of marked subexpressions within the regular
723  * expression.
724  */
725  unsigned int
726  mark_count() const noexcept
727  {
728  if (_M_automaton)
729  return _M_automaton->_M_sub_count() - 1;
730  return 0;
731  }
732 
733  /**
734  * @brief Gets the flags used to construct the regular expression
735  * or in the last call to assign().
736  */
737  flag_type
738  flags() const noexcept
739  { return _M_flags; }
740 
741  // [7.8.5] locale
742  /**
743  * @brief Imbues the regular expression object with the given locale.
744  *
745  * @param __loc A locale.
746  */
747  locale_type
748  imbue(locale_type __loc)
749  {
750  std::swap(__loc, _M_loc);
751  _M_automaton.reset();
752  return __loc;
753  }
754 
755  /**
756  * @brief Gets the locale currently imbued in the regular expression
757  * object.
758  */
759  locale_type
760  getloc() const noexcept
761  { return _M_loc; }
762 
763  // [7.8.6] swap
764  /**
765  * @brief Swaps the contents of two regular expression objects.
766  *
767  * @param __rhs Another regular expression object.
768  */
769  void
770  swap(basic_regex& __rhs) noexcept
771  {
772  std::swap(_M_flags, __rhs._M_flags);
773  std::swap(_M_loc, __rhs._M_loc);
774  std::swap(_M_automaton, __rhs._M_automaton);
775  }
776 
777 #ifdef _GLIBCXX_DEBUG
778  void
779  _M_dot(std::ostream& __ostr)
780  { _M_automaton->_M_dot(__ostr); }
781 #endif
782 
783  private:
785 
786  void
787  _M_compile(const _Ch_type* __first, const _Ch_type* __last,
788  flag_type __f)
789  {
790  __detail::_Compiler<_Rx_traits> __c(__first, __last, _M_loc, __f);
791  _M_automaton = __c._M_get_nfa();
792  _M_flags = __f;
793  }
794 
795  template<typename _Bp, typename _Ap, typename _Cp, typename _Rp,
796  __detail::_RegexExecutorPolicy, bool>
797  friend bool
798  __detail::__regex_algo_impl(_Bp, _Bp, match_results<_Bp, _Ap>&,
799  const basic_regex<_Cp, _Rp>&,
801 
802  template<typename, typename, typename, bool>
803  friend class __detail::_Executor;
804 
805  flag_type _M_flags;
806  locale_type _M_loc;
807  _AutomatonPtr _M_automaton;
808  };
809 
810 #if ! __cpp_inline_variables
811  template<typename _Ch, typename _Tr>
814 
815  template<typename _Ch, typename _Tr>
818 
819  template<typename _Ch, typename _Tr>
822 
823  template<typename _Ch, typename _Tr>
826 
827  template<typename _Ch, typename _Tr>
830 
831  template<typename _Ch, typename _Tr>
834 
835  template<typename _Ch, typename _Tr>
838 
839  template<typename _Ch, typename _Tr>
842 
843  template<typename _Ch, typename _Tr>
846 
847  template<typename _Ch, typename _Tr>
850 #endif // ! C++17
851 
852 #if __cpp_deduction_guides >= 201606
853  template<typename _ForwardIterator>
854  basic_regex(_ForwardIterator, _ForwardIterator,
856  -> basic_regex<typename iterator_traits<_ForwardIterator>::value_type>;
857 #endif
858 
859  /** @brief Standard regular expressions. */
861 
862 #ifdef _GLIBCXX_USE_WCHAR_T
863  /** @brief Standard wide-character regular expressions. */
865 #endif
866 
867 
868  // [7.8.6] basic_regex swap
869  /**
870  * @brief Swaps the contents of two regular expression objects.
871  * @param __lhs First regular expression.
872  * @param __rhs Second regular expression.
873  * @relates basic_regex
874  */
875  template<typename _Ch_type, typename _Rx_traits>
876  inline void
878  basic_regex<_Ch_type, _Rx_traits>& __rhs) noexcept
879  { __lhs.swap(__rhs); }
880 
881 
882  // C++11 28.9 [re.submatch] Class template sub_match
883  /**
884  * A sequence of characters matched by a particular marked sub-expression.
885  *
886  * An object of this class is essentially a pair of iterators marking a
887  * matched subexpression within a regular expression pattern match. Such
888  * objects can be converted to and compared with std::basic_string objects
889  * of a similar base character type as the pattern matched by the regular
890  * expression.
891  *
892  * The iterators that make up the pair are the usual half-open interval
893  * referencing the actual original pattern matched.
894  */
895  template<typename _BiIter>
896  class sub_match : public std::pair<_BiIter, _BiIter>
897  {
899 
900  public:
901  typedef typename __iter_traits::value_type value_type;
902  typedef typename __iter_traits::difference_type difference_type;
903  typedef _BiIter iterator;
905 
906  bool matched;
907 
908  constexpr sub_match() noexcept : matched() { }
909 
910  /// Gets the length of the matching sequence.
911  difference_type
912  length() const noexcept
913  { return this->matched ? std::distance(this->first, this->second) : 0; }
914 
915  /**
916  * @brief Gets the matching sequence as a string.
917  *
918  * @returns the matching sequence as a string.
919  *
920  * This is the implicit conversion operator. It is identical to the
921  * str() member function except that it will want to pop up in
922  * unexpected places and cause a great deal of confusion and cursing
923  * from the unwary.
924  */
925  operator string_type() const
926  { return str(); }
927 
928  /**
929  * @brief Gets the matching sequence as a string.
930  *
931  * @returns the matching sequence as a string.
932  */
933  string_type
934  str() const
935  {
936  return this->matched
937  ? string_type(this->first, this->second)
938  : string_type();
939  }
940 
941  /**
942  * @brief Compares this and another matched sequence.
943  *
944  * @param __s Another matched sequence to compare to this one.
945  *
946  * @retval negative This matched sequence will collate before `__s`.
947  * @retval zero This matched sequence is equivalent to `__s`.
948  * @retval positive This matched sequence will collate after `__s`.
949  */
950  int
951  compare(const sub_match& __s) const
952  { return this->_M_str().compare(__s._M_str()); }
953 
954  /**
955  * @{
956  * @brief Compares this `sub_match` to a string.
957  *
958  * @param __s A string to compare to this `sub_match`.
959  *
960  * @retval negative This matched sequence will collate before `__s`.
961  * @retval zero This matched sequence is equivalent to `__s`.
962  * @retval positive This matched sequence will collate after `__s`.
963  */
964  int
965  compare(const string_type& __s) const
966  { return this->_M_str().compare(__s); }
967 
968  int
969  compare(const value_type* __s) const
970  { return this->_M_str().compare(__s); }
971  /// @}
972 
973  /// @cond undocumented
974  // Non-standard, used by comparison operators
975  int
976  _M_compare(const value_type* __s, size_t __n) const
977  { return this->_M_str().compare({__s, __n}); }
978  /// @endcond
979 
980  private:
981  // Simplified basic_string_view for C++11
982  struct __string_view
983  {
984  using traits_type = typename string_type::traits_type;
985 
986  __string_view() = default;
987 
988  __string_view(const value_type* __s, size_t __n) noexcept
989  : _M_data(__s), _M_len(__n) { }
990 
991  __string_view(const value_type* __s) noexcept
992  : _M_data(__s), _M_len(traits_type::length(__s)) { }
993 
994  __string_view(const string_type& __s) noexcept
995  : _M_data(__s.data()), _M_len(__s.length()) { }
996 
997  int
998  compare(__string_view __s) const noexcept
999  {
1000  if (const size_t __n = std::min(_M_len, __s._M_len))
1001  if (int __ret = traits_type::compare(_M_data, __s._M_data, __n))
1002  return __ret;
1003  using __limits = __gnu_cxx::__int_traits<int>;
1004  const difference_type __diff = _M_len - __s._M_len;
1005  if (__diff > __limits::__max)
1006  return __limits::__max;
1007  if (__diff < __limits::__min)
1008  return __limits::__min;
1009  return static_cast<int>(__diff);
1010  }
1011 
1012  private:
1013  const value_type* _M_data = nullptr;
1014  size_t _M_len = 0;
1015  };
1016 
1017  // Create a __string_view over the iterator range.
1018  template<typename _Iter = _BiIter>
1019  __enable_if_t<__detail::__is_contiguous_iter<_Iter>::value,
1020  __string_view>
1021  _M_str() const noexcept
1022  {
1023  if (this->matched)
1024  if (size_t __len = this->second - this->first)
1025  return { std::__addressof(*this->first), __len };
1026  return {};
1027  }
1028 
1029  // Create a temporary string that can be converted to __string_view.
1030  template<typename _Iter = _BiIter>
1031  __enable_if_t<!__detail::__is_contiguous_iter<_Iter>::value,
1032  string_type>
1033  _M_str() const
1034  { return str(); }
1035  };
1036 
1037 
1038  /** @brief Standard regex submatch over a C-style null-terminated string. */
1040 
1041  /** @brief Standard regex submatch over a standard string. */
1043 
1044 #ifdef _GLIBCXX_USE_WCHAR_T
1045  /** @brief Regex submatch over a C-style null-terminated wide string. */
1047 
1048  /** @brief Regex submatch over a standard wide string. */
1050 #endif
1051 
1052  // [7.9.2] sub_match non-member operators
1053 
1054  /// @relates sub_match @{
1055 
1056  /**
1057  * @brief Tests the equivalence of two regular expression submatches.
1058  * @param __lhs First regular expression submatch.
1059  * @param __rhs Second regular expression submatch.
1060  * @returns true if @a __lhs is equivalent to @a __rhs, false otherwise.
1061  */
1062  template<typename _BiIter>
1063  inline bool
1065  { return __lhs.compare(__rhs) == 0; }
1066 
1067 #if __cpp_lib_three_way_comparison
1068  /**
1069  * @brief Three-way comparison of two regular expression submatches.
1070  * @param __lhs First regular expression submatch.
1071  * @param __rhs Second regular expression submatch.
1072  * @returns A value indicating whether `__lhs` is less than, equal to,
1073  * greater than, or incomparable with `__rhs`.
1074  */
1075  template<typename _BiIter>
1076  inline auto
1077  operator<=>(const sub_match<_BiIter>& __lhs,
1078  const sub_match<_BiIter>& __rhs)
1079  noexcept(__detail::__is_contiguous_iter<_BiIter>::value)
1080  {
1082  return __detail::__char_traits_cmp_cat<_Tr>(__lhs.compare(__rhs));
1083  }
1084 #else
1085  /**
1086  * @brief Tests the inequivalence of two regular expression submatches.
1087  * @param __lhs First regular expression submatch.
1088  * @param __rhs Second regular expression submatch.
1089  * @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise.
1090  */
1091  template<typename _BiIter>
1092  inline bool
1094  { return __lhs.compare(__rhs) != 0; }
1095 
1096  /**
1097  * @brief Tests the ordering of two regular expression submatches.
1098  * @param __lhs First regular expression submatch.
1099  * @param __rhs Second regular expression submatch.
1100  * @returns true if @a __lhs precedes @a __rhs, false otherwise.
1101  */
1102  template<typename _BiIter>
1103  inline bool
1104  operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
1105  { return __lhs.compare(__rhs) < 0; }
1106 
1107  /**
1108  * @brief Tests the ordering of two regular expression submatches.
1109  * @param __lhs First regular expression submatch.
1110  * @param __rhs Second regular expression submatch.
1111  * @returns true if @a __lhs does not succeed @a __rhs, false otherwise.
1112  */
1113  template<typename _BiIter>
1114  inline bool
1115  operator<=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
1116  { return __lhs.compare(__rhs) <= 0; }
1117 
1118  /**
1119  * @brief Tests the ordering of two regular expression submatches.
1120  * @param __lhs First regular expression submatch.
1121  * @param __rhs Second regular expression submatch.
1122  * @returns true if @a __lhs does not precede @a __rhs, false otherwise.
1123  */
1124  template<typename _BiIter>
1125  inline bool
1127  { return __lhs.compare(__rhs) >= 0; }
1128 
1129  /**
1130  * @brief Tests the ordering of two regular expression submatches.
1131  * @param __lhs First regular expression submatch.
1132  * @param __rhs Second regular expression submatch.
1133  * @returns true if @a __lhs succeeds @a __rhs, false otherwise.
1134  */
1135  template<typename _BiIter>
1136  inline bool
1138  { return __lhs.compare(__rhs) > 0; }
1139 #endif // three-way comparison
1140 
1141  /// @cond undocumented
1142 
1143  // Alias for a basic_string that can be compared to a sub_match.
1144  template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
1145  using __sub_match_string = basic_string<
1147  _Ch_traits, _Ch_alloc>;
1148  /// @endcond
1149 
1150 #if ! __cpp_lib_three_way_comparison
1151  /**
1152  * @brief Tests the equivalence of a string and a regular expression
1153  * submatch.
1154  * @param __lhs A string.
1155  * @param __rhs A regular expression submatch.
1156  * @returns true if @a __lhs is equivalent to @a __rhs, false otherwise.
1157  */
1158  template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
1159  inline bool
1160  operator==(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
1161  const sub_match<_Bi_iter>& __rhs)
1162  { return __rhs._M_compare(__lhs.data(), __lhs.size()) == 0; }
1163 
1164  /**
1165  * @brief Tests the inequivalence of a string and a regular expression
1166  * submatch.
1167  * @param __lhs A string.
1168  * @param __rhs A regular expression submatch.
1169  * @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise.
1170  */
1171  template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
1172  inline bool
1173  operator!=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
1174  const sub_match<_Bi_iter>& __rhs)
1175  { return !(__lhs == __rhs); }
1176 
1177  /**
1178  * @brief Tests the ordering of a string and a regular expression submatch.
1179  * @param __lhs A string.
1180  * @param __rhs A regular expression submatch.
1181  * @returns true if @a __lhs precedes @a __rhs, false otherwise.
1182  */
1183  template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
1184  inline bool
1185  operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
1186  const sub_match<_Bi_iter>& __rhs)
1187  { return __rhs._M_compare(__lhs.data(), __lhs.size()) > 0; }
1188 
1189  /**
1190  * @brief Tests the ordering of a string and a regular expression submatch.
1191  * @param __lhs A string.
1192  * @param __rhs A regular expression submatch.
1193  * @returns true if @a __lhs succeeds @a __rhs, false otherwise.
1194  */
1195  template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
1196  inline bool
1197  operator>(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
1198  const sub_match<_Bi_iter>& __rhs)
1199  { return __rhs < __lhs; }
1200 
1201  /**
1202  * @brief Tests the ordering of a string and a regular expression submatch.
1203  * @param __lhs A string.
1204  * @param __rhs A regular expression submatch.
1205  * @returns true if @a __lhs does not precede @a __rhs, false otherwise.
1206  */
1207  template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
1208  inline bool
1209  operator>=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
1210  const sub_match<_Bi_iter>& __rhs)
1211  { return !(__lhs < __rhs); }
1212 
1213  /**
1214  * @brief Tests the ordering of a string and a regular expression submatch.
1215  * @param __lhs A string.
1216  * @param __rhs A regular expression submatch.
1217  * @returns true if @a __lhs does not succeed @a __rhs, false otherwise.
1218  */
1219  template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
1220  inline bool
1221  operator<=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
1222  const sub_match<_Bi_iter>& __rhs)
1223  { return !(__rhs < __lhs); }
1224 #endif // three-way comparison
1225 
1226  /**
1227  * @brief Tests the equivalence of a regular expression submatch and a
1228  * string.
1229  * @param __lhs A regular expression submatch.
1230  * @param __rhs A string.
1231  * @returns true if @a __lhs is equivalent to @a __rhs, false otherwise.
1232  */
1233  template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
1234  inline bool
1236  const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
1237  { return __lhs._M_compare(__rhs.data(), __rhs.size()) == 0; }
1238 
1239 #if __cpp_lib_three_way_comparison
1240  /**
1241  * @brief Three-way comparison of a regular expression submatch and a string.
1242  * @param __lhs A regular expression submatch.
1243  * @param __rhs A string.
1244  * @returns A value indicating whether `__lhs` is less than, equal to,
1245  * greater than, or incomparable with `__rhs`.
1246  */
1247  template<typename _Bi_iter, typename _Ch_traits, typename _Alloc>
1248  inline auto
1249  operator<=>(const sub_match<_Bi_iter>& __lhs,
1250  const __sub_match_string<_Bi_iter, _Ch_traits, _Alloc>& __rhs)
1251  noexcept(__detail::__is_contiguous_iter<_Bi_iter>::value)
1252  {
1253  return __detail::__char_traits_cmp_cat<_Ch_traits>(
1254  __lhs._M_compare(__rhs.data(), __rhs.size()));
1255  }
1256 #else
1257  /**
1258  * @brief Tests the inequivalence of a regular expression submatch and a
1259  * string.
1260  * @param __lhs A regular expression submatch.
1261  * @param __rhs A string.
1262  * @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise.
1263  */
1264  template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
1265  inline bool
1267  const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
1268  { return !(__lhs == __rhs); }
1269 
1270  /**
1271  * @brief Tests the ordering of a regular expression submatch and a string.
1272  * @param __lhs A regular expression submatch.
1273  * @param __rhs A string.
1274  * @returns true if @a __lhs precedes @a __rhs, false otherwise.
1275  */
1276  template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
1277  inline bool
1278  operator<(const sub_match<_Bi_iter>& __lhs,
1279  const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
1280  { return __lhs._M_compare(__rhs.data(), __rhs.size()) < 0; }
1281 
1282  /**
1283  * @brief Tests the ordering of a regular expression submatch and a string.
1284  * @param __lhs A regular expression submatch.
1285  * @param __rhs A string.
1286  * @returns true if @a __lhs succeeds @a __rhs, false otherwise.
1287  */
1288  template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
1289  inline bool
1291  const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
1292  { return __rhs < __lhs; }
1293 
1294  /**
1295  * @brief Tests the ordering of a regular expression submatch and a string.
1296  * @param __lhs A regular expression submatch.
1297  * @param __rhs A string.
1298  * @returns true if @a __lhs does not precede @a __rhs, false otherwise.
1299  */
1300  template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
1301  inline bool
1303  const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
1304  { return !(__lhs < __rhs); }
1305 
1306  /**
1307  * @brief Tests the ordering of a regular expression submatch and a string.
1308  * @param __lhs A regular expression submatch.
1309  * @param __rhs A string.
1310  * @returns true if @a __lhs does not succeed @a __rhs, false otherwise.
1311  */
1312  template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
1313  inline bool
1314  operator<=(const sub_match<_Bi_iter>& __lhs,
1315  const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
1316  { return !(__rhs < __lhs); }
1317 
1318  /**
1319  * @brief Tests the equivalence of a C string and a regular expression
1320  * submatch.
1321  * @param __lhs A null-terminated string.
1322  * @param __rhs A regular expression submatch.
1323  * @returns true if @a __lhs is equivalent to @a __rhs, false otherwise.
1324  */
1325  template<typename _Bi_iter>
1326  inline bool
1328  const sub_match<_Bi_iter>& __rhs)
1329  { return __rhs.compare(__lhs) == 0; }
1330 
1331  /**
1332  * @brief Tests the inequivalence of a C string and a regular
1333  * expression submatch.
1334  * @param __lhs A null-terminated string.
1335  * @param __rhs A regular expression submatch.
1336  * @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise.
1337  */
1338  template<typename _Bi_iter>
1339  inline bool
1341  const sub_match<_Bi_iter>& __rhs)
1342  { return !(__lhs == __rhs); }
1343 
1344  /**
1345  * @brief Tests the ordering of a C string and a regular expression submatch.
1346  * @param __lhs A null-terminated string.
1347  * @param __rhs A regular expression submatch.
1348  * @returns true if @a __lhs precedes @a __rhs, false otherwise.
1349  */
1350  template<typename _Bi_iter>
1351  inline bool
1352  operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
1353  const sub_match<_Bi_iter>& __rhs)
1354  { return __rhs.compare(__lhs) > 0; }
1355 
1356  /**
1357  * @brief Tests the ordering of a C string and a regular expression submatch.
1358  * @param __lhs A null-terminated string.
1359  * @param __rhs A regular expression submatch.
1360  * @returns true if @a __lhs succeeds @a __rhs, false otherwise.
1361  */
1362  template<typename _Bi_iter>
1363  inline bool
1365  const sub_match<_Bi_iter>& __rhs)
1366  { return __rhs < __lhs; }
1367 
1368  /**
1369  * @brief Tests the ordering of a C string and a regular expression submatch.
1370  * @param __lhs A null-terminated string.
1371  * @param __rhs A regular expression submatch.
1372  * @returns true if @a __lhs does not precede @a __rhs, false otherwise.
1373  */
1374  template<typename _Bi_iter>
1375  inline bool
1377  const sub_match<_Bi_iter>& __rhs)
1378  { return !(__lhs < __rhs); }
1379 
1380  /**
1381  * @brief Tests the ordering of a C string and a regular expression submatch.
1382  * @param __lhs A null-terminated string.
1383  * @param __rhs A regular expression submatch.
1384  * @returns true if @a __lhs does not succeed @a __rhs, false otherwise.
1385  */
1386  template<typename _Bi_iter>
1387  inline bool
1388  operator<=(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
1389  const sub_match<_Bi_iter>& __rhs)
1390  { return !(__rhs < __lhs); }
1391 #endif // three-way comparison
1392 
1393  /**
1394  * @brief Tests the equivalence of a regular expression submatch and a C
1395  * string.
1396  * @param __lhs A regular expression submatch.
1397  * @param __rhs A null-terminated string.
1398  * @returns true if @a __lhs is equivalent to @a __rhs, false otherwise.
1399  */
1400  template<typename _Bi_iter>
1401  inline bool
1403  typename iterator_traits<_Bi_iter>::value_type const* __rhs)
1404  { return __lhs.compare(__rhs) == 0; }
1405 
1406 #if __cpp_lib_three_way_comparison
1407  /**
1408  * @brief Three-way comparison of a regular expression submatch and a C
1409  * string.
1410  * @param __lhs A regular expression submatch.
1411  * @param __rhs A null-terminated string.
1412  * @returns A value indicating whether `__lhs` is less than, equal to,
1413  * greater than, or incomparable with `__rhs`.
1414  */
1415  template<typename _Bi_iter>
1416  inline auto
1417  operator<=>(const sub_match<_Bi_iter>& __lhs,
1418  typename iterator_traits<_Bi_iter>::value_type const* __rhs)
1419  noexcept(__detail::__is_contiguous_iter<_Bi_iter>::value)
1420  {
1422  return __detail::__char_traits_cmp_cat<_Tr>(__lhs.compare(__rhs));
1423  }
1424 #else
1425  /**
1426  * @brief Tests the inequivalence of a regular expression submatch and a
1427  * string.
1428  * @param __lhs A regular expression submatch.
1429  * @param __rhs A null-terminated string.
1430  * @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise.
1431  */
1432  template<typename _Bi_iter>
1433  inline bool
1435  typename iterator_traits<_Bi_iter>::value_type const* __rhs)
1436  { return !(__lhs == __rhs); }
1437 
1438  /**
1439  * @brief Tests the ordering of a regular expression submatch and a C string.
1440  * @param __lhs A regular expression submatch.
1441  * @param __rhs A null-terminated string.
1442  * @returns true if @a __lhs precedes @a __rhs, false otherwise.
1443  */
1444  template<typename _Bi_iter>
1445  inline bool
1446  operator<(const sub_match<_Bi_iter>& __lhs,
1447  typename iterator_traits<_Bi_iter>::value_type const* __rhs)
1448  { return __lhs.compare(__rhs) < 0; }
1449 
1450  /**
1451  * @brief Tests the ordering of a regular expression submatch and a C string.
1452  * @param __lhs A regular expression submatch.
1453  * @param __rhs A null-terminated string.
1454  * @returns true if @a __lhs succeeds @a __rhs, false otherwise.
1455  */
1456  template<typename _Bi_iter>
1457  inline bool
1459  typename iterator_traits<_Bi_iter>::value_type const* __rhs)
1460  { return __rhs < __lhs; }
1461 
1462  /**
1463  * @brief Tests the ordering of a regular expression submatch and a C string.
1464  * @param __lhs A regular expression submatch.
1465  * @param __rhs A null-terminated string.
1466  * @returns true if @a __lhs does not precede @a __rhs, false otherwise.
1467  */
1468  template<typename _Bi_iter>
1469  inline bool
1471  typename iterator_traits<_Bi_iter>::value_type const* __rhs)
1472  { return !(__lhs < __rhs); }
1473 
1474  /**
1475  * @brief Tests the ordering of a regular expression submatch and a C string.
1476  * @param __lhs A regular expression submatch.
1477  * @param __rhs A null-terminated string.
1478  * @returns true if @a __lhs does not succeed @a __rhs, false otherwise.
1479  */
1480  template<typename _Bi_iter>
1481  inline bool
1482  operator<=(const sub_match<_Bi_iter>& __lhs,
1483  typename iterator_traits<_Bi_iter>::value_type const* __rhs)
1484  { return !(__rhs < __lhs); }
1485 
1486  /**
1487  * @brief Tests the equivalence of a character and a regular expression
1488  * submatch.
1489  * @param __lhs A character.
1490  * @param __rhs A regular expression submatch.
1491  * @returns true if @a __lhs is equivalent to @a __rhs, false otherwise.
1492  */
1493  template<typename _Bi_iter>
1494  inline bool
1496  const sub_match<_Bi_iter>& __rhs)
1497  { return __rhs._M_compare(std::__addressof(__lhs), 1) == 0; }
1498 
1499  /**
1500  * @brief Tests the inequivalence of a character and a regular expression
1501  * submatch.
1502  * @param __lhs A character.
1503  * @param __rhs A regular expression submatch.
1504  * @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise.
1505  */
1506  template<typename _Bi_iter>
1507  inline bool
1509  const sub_match<_Bi_iter>& __rhs)
1510  { return !(__lhs == __rhs); }
1511 
1512  /**
1513  * @brief Tests the ordering of a character and a regular expression
1514  * submatch.
1515  * @param __lhs A character.
1516  * @param __rhs A regular expression submatch.
1517  * @returns true if @a __lhs precedes @a __rhs, false otherwise.
1518  */
1519  template<typename _Bi_iter>
1520  inline bool
1521  operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
1522  const sub_match<_Bi_iter>& __rhs)
1523  { return __rhs._M_compare(std::__addressof(__lhs), 1) > 0; }
1524 
1525  /**
1526  * @brief Tests the ordering of a character and a regular expression
1527  * submatch.
1528  * @param __lhs A character.
1529  * @param __rhs A regular expression submatch.
1530  * @returns true if @a __lhs succeeds @a __rhs, false otherwise.
1531  */
1532  template<typename _Bi_iter>
1533  inline bool
1535  const sub_match<_Bi_iter>& __rhs)
1536  { return __rhs < __lhs; }
1537 
1538  /**
1539  * @brief Tests the ordering of a character and a regular expression
1540  * submatch.
1541  * @param __lhs A character.
1542  * @param __rhs A regular expression submatch.
1543  * @returns true if @a __lhs does not precede @a __rhs, false otherwise.
1544  */
1545  template<typename _Bi_iter>
1546  inline bool
1548  const sub_match<_Bi_iter>& __rhs)
1549  { return !(__lhs < __rhs); }
1550 
1551  /**
1552  * @brief Tests the ordering of a character and a regular expression
1553  * submatch.
1554  * @param __lhs A character.
1555  * @param __rhs A regular expression submatch.
1556  * @returns true if @a __lhs does not succeed @a __rhs, false otherwise.
1557  */
1558  template<typename _Bi_iter>
1559  inline bool
1560  operator<=(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
1561  const sub_match<_Bi_iter>& __rhs)
1562  { return !(__rhs < __lhs); }
1563 #endif // three-way comparison
1564 
1565  /**
1566  * @brief Tests the equivalence of a regular expression submatch and a
1567  * character.
1568  * @param __lhs A regular expression submatch.
1569  * @param __rhs A character.
1570  * @returns true if @a __lhs is equivalent to @a __rhs, false otherwise.
1571  */
1572  template<typename _Bi_iter>
1573  inline bool
1575  typename iterator_traits<_Bi_iter>::value_type const& __rhs)
1576  { return __lhs._M_compare(std::__addressof(__rhs), 1) == 0; }
1577 
1578 #if __cpp_lib_three_way_comparison
1579  /**
1580  * @brief Three-way comparison of a regular expression submatch and a
1581  * character.
1582  * @param __lhs A regular expression submatch.
1583  * @param __rhs A character.
1584  * @returns A value indicating whether `__lhs` is less than, equal to,
1585  * greater than, or incomparable with `__rhs`.
1586  */
1587 
1588  template<typename _Bi_iter>
1589  inline auto
1590  operator<=>(const sub_match<_Bi_iter>& __lhs,
1591  typename iterator_traits<_Bi_iter>::value_type const& __rhs)
1592  noexcept(__detail::__is_contiguous_iter<_Bi_iter>::value)
1593  {
1595  return __detail::__char_traits_cmp_cat<_Tr>(
1596  __lhs._M_compare(std::__addressof(__rhs), 1));
1597  }
1598 #else
1599  /**
1600  * @brief Tests the inequivalence of a regular expression submatch and a
1601  * character.
1602  * @param __lhs A regular expression submatch.
1603  * @param __rhs A character.
1604  * @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise.
1605  */
1606  template<typename _Bi_iter>
1607  inline bool
1609  typename iterator_traits<_Bi_iter>::value_type const& __rhs)
1610  { return !(__lhs == __rhs); }
1611 
1612  /**
1613  * @brief Tests the ordering of a regular expression submatch and a
1614  * character.
1615  * @param __lhs A regular expression submatch.
1616  * @param __rhs A character.
1617  * @returns true if @a __lhs precedes @a __rhs, false otherwise.
1618  */
1619  template<typename _Bi_iter>
1620  inline bool
1621  operator<(const sub_match<_Bi_iter>& __lhs,
1622  typename iterator_traits<_Bi_iter>::value_type const& __rhs)
1623  { return __lhs._M_compare(std::__addressof(__rhs), 1) < 0; }
1624 
1625  /**
1626  * @brief Tests the ordering of a regular expression submatch and a
1627  * character.
1628  * @param __lhs A regular expression submatch.
1629  * @param __rhs A character.
1630  * @returns true if @a __lhs succeeds @a __rhs, false otherwise.
1631  */
1632  template<typename _Bi_iter>
1633  inline bool
1635  typename iterator_traits<_Bi_iter>::value_type const& __rhs)
1636  { return __rhs < __lhs; }
1637 
1638  /**
1639  * @brief Tests the ordering of a regular expression submatch and a
1640  * character.
1641  * @param __lhs A regular expression submatch.
1642  * @param __rhs A character.
1643  * @returns true if @a __lhs does not precede @a __rhs, false otherwise.
1644  */
1645  template<typename _Bi_iter>
1646  inline bool
1648  typename iterator_traits<_Bi_iter>::value_type const& __rhs)
1649  { return !(__lhs < __rhs); }
1650 
1651  /**
1652  * @brief Tests the ordering of a regular expression submatch and a
1653  * character.
1654  * @param __lhs A regular expression submatch.
1655  * @param __rhs A character.
1656  * @returns true if @a __lhs does not succeed @a __rhs, false otherwise.
1657  */
1658  template<typename _Bi_iter>
1659  inline bool
1660  operator<=(const sub_match<_Bi_iter>& __lhs,
1661  typename iterator_traits<_Bi_iter>::value_type const& __rhs)
1662  { return !(__rhs < __lhs); }
1663 #endif // three-way comparison
1664 
1665  /**
1666  * @brief Inserts a matched string into an output stream.
1667  *
1668  * @param __os The output stream.
1669  * @param __m A submatch string.
1670  *
1671  * @returns the output stream with the submatch string inserted.
1672  */
1673  template<typename _Ch_type, typename _Ch_traits, typename _Bi_iter>
1674  inline
1677  const sub_match<_Bi_iter>& __m)
1678  { return __os << __m.str(); }
1679 
1680  /// @} relates sub_match
1681 
1682  // [7.10] Class template match_results
1683 
1684  /**
1685  * @brief The results of a match or search operation.
1686  *
1687  * A collection of character sequences representing the result of a regular
1688  * expression match. Storage for the collection is allocated and freed as
1689  * necessary by the member functions of class template match_results.
1690  *
1691  * This class satisfies the Sequence requirements, with the exception that
1692  * only the operations defined for a const-qualified Sequence are supported.
1693  *
1694  * The sub_match object stored at index 0 represents sub-expression 0, i.e.
1695  * the whole match. In this case the %sub_match member matched is always true.
1696  * The sub_match object stored at index n denotes what matched the marked
1697  * sub-expression n within the matched expression. If the sub-expression n
1698  * participated in a regular expression match then the %sub_match member
1699  * matched evaluates to true, and members first and second denote the range
1700  * of characters [first, second) which formed that match. Otherwise matched
1701  * is false, and members first and second point to the end of the sequence
1702  * that was searched.
1703  */
1704  template<typename _Bi_iter,
1705  typename _Alloc = allocator<sub_match<_Bi_iter> > >
1707  : private std::vector<sub_match<_Bi_iter>, _Alloc>
1708  {
1709  private:
1710  /*
1711  * The vector base is empty if this does not represent a match (!ready());
1712  * Otherwise if it's a match failure, it contains 3 elements:
1713  * [0] unmatched
1714  * [1] prefix
1715  * [2] suffix
1716  * Otherwise it contains n+4 elements where n is the number of marked
1717  * sub-expressions:
1718  * [0] entire match
1719  * [1] 1st marked subexpression
1720  * ...
1721  * [n] nth marked subexpression
1722  * [n+1] unmatched
1723  * [n+2] prefix
1724  * [n+3] suffix
1725  */
1727  // In debug mode _Base_type is the debug vector, this is the unsafe one:
1728  typedef _GLIBCXX_STD_C::vector<sub_match<_Bi_iter>, _Alloc> _Unchecked;
1731 
1732  public:
1733  /**
1734  * @name 28.10 Public Types
1735  */
1736  ///@{
1738  typedef const value_type& const_reference;
1739  typedef value_type& reference;
1740  typedef typename _Base_type::const_iterator const_iterator;
1741  typedef const_iterator iterator;
1742  typedef typename __iter_traits::difference_type difference_type;
1743  typedef typename allocator_traits<_Alloc>::size_type size_type;
1744  typedef _Alloc allocator_type;
1745  typedef typename __iter_traits::value_type char_type;
1747  ///@}
1748 
1749  public:
1750  /**
1751  * @name 28.10.1 Construction, Copying, and Destruction
1752  */
1753  ///@{
1754 
1755  /**
1756  * @brief Constructs a default %match_results container.
1757  * @post size() returns 0 and str() returns an empty string.
1758  */
1759  match_results() : match_results(_Alloc()) { }
1760 
1761  /**
1762  * @brief Constructs a default %match_results container.
1763  * @post size() returns 0 and str() returns an empty string.
1764  */
1765  explicit
1766  match_results(const _Alloc& __a) noexcept
1767  : _Base_type(__a)
1768  { }
1769 
1770  /**
1771  * @brief Copy constructs a %match_results.
1772  */
1773  match_results(const match_results&) = default;
1774 
1775  /**
1776  * @brief Move constructs a %match_results.
1777  */
1778  match_results(match_results&&) noexcept = default;
1779 
1780  /**
1781  * @brief Assigns rhs to *this.
1782  */
1783  match_results&
1784  operator=(const match_results&) = default;
1785 
1786  /**
1787  * @brief Move-assigns rhs to *this.
1788  */
1789  match_results&
1790  operator=(match_results&&) = default;
1791 
1792  /**
1793  * @brief Destroys a %match_results object.
1794  */
1795  ~match_results() = default;
1796 
1797  ///@}
1798 
1799  // 28.10.2, state:
1800  /**
1801  * @brief Indicates if the %match_results is ready.
1802  * @retval true The object has a fully-established result state.
1803  * @retval false The object is not ready.
1804  */
1805  bool ready() const noexcept { return !_Unchecked::empty(); }
1806 
1807  /**
1808  * @name 28.10.2 Size
1809  */
1810  ///@{
1811 
1812  /**
1813  * @brief Gets the number of matches and submatches.
1814  *
1815  * The number of matches for a given regular expression will be either 0
1816  * if there was no match or mark_count() + 1 if a match was successful.
1817  * Some matches may be empty.
1818  *
1819  * @returns the number of matches found.
1820  */
1821  size_type
1822  size() const noexcept
1823  { return _Unchecked::empty() ? 0 : _Unchecked::size() - 3; }
1824 
1825  size_type
1826  max_size() const noexcept
1827  { return _Unchecked::max_size() - 3; }
1828 
1829  /**
1830  * @brief Indicates if the %match_results contains no results.
1831  * @retval true The %match_results object is empty.
1832  * @retval false The %match_results object is not empty.
1833  */
1834  _GLIBCXX_NODISCARD bool
1835  empty() const noexcept
1836  { return _Unchecked::size() <= 3; }
1837 
1838  ///@}
1839 
1840  /**
1841  * @name 28.10.4 Element Access
1842  */
1843  ///@{
1844 
1845  /**
1846  * @brief Gets the length of the indicated submatch.
1847  * @param __sub indicates the submatch.
1848  * @pre ready() == true
1849  *
1850  * This function returns the length of the indicated submatch, or the
1851  * length of the entire match if @p __sub is zero (the default).
1852  */
1853  difference_type
1854  length(size_type __sub = 0) const
1855  { return (*this)[__sub].length(); }
1856 
1857  /**
1858  * @brief Gets the offset of the beginning of the indicated submatch.
1859  * @param __sub indicates the submatch.
1860  * @pre ready() == true
1861  *
1862  * This function returns the offset from the beginning of the target
1863  * sequence to the beginning of the submatch, unless the value of @p __sub
1864  * is zero (the default), in which case this function returns the offset
1865  * from the beginning of the target sequence to the beginning of the
1866  * match.
1867  */
1868  difference_type
1869  position(size_type __sub = 0) const
1870  { return std::distance(_M_begin, (*this)[__sub].first); }
1871 
1872  /**
1873  * @brief Gets the match or submatch converted to a string type.
1874  * @param __sub indicates the submatch.
1875  * @pre ready() == true
1876  *
1877  * This function gets the submatch (or match, if @p __sub is
1878  * zero) extracted from the target range and converted to the
1879  * associated string type.
1880  */
1881  string_type
1882  str(size_type __sub = 0) const
1883  { return string_type((*this)[__sub]); }
1884 
1885  /**
1886  * @brief Gets a %sub_match reference for the match or submatch.
1887  * @param __sub indicates the submatch.
1888  * @pre ready() == true
1889  *
1890  * This function gets a reference to the indicated submatch, or
1891  * the entire match if @p __sub is zero.
1892  *
1893  * If @p __sub >= size() then this function returns a %sub_match with a
1894  * special value indicating no submatch.
1895  */
1896  const_reference
1897  operator[](size_type __sub) const
1898  {
1899  __glibcxx_assert( ready() );
1900  return __sub < size()
1901  ? _Unchecked::operator[](__sub)
1902  : _M_unmatched_sub();
1903  }
1904 
1905  /**
1906  * @brief Gets a %sub_match representing the match prefix.
1907  * @pre ready() == true
1908  *
1909  * This function gets a reference to a %sub_match object representing the
1910  * part of the target range between the start of the target range and the
1911  * start of the match.
1912  */
1913  const_reference
1914  prefix() const
1915  {
1916  __glibcxx_assert( ready() );
1917  return !empty() ? _M_prefix() : _M_unmatched_sub();
1918  }
1919 
1920  /**
1921  * @brief Gets a %sub_match representing the match suffix.
1922  * @pre ready() == true
1923  *
1924  * This function gets a reference to a %sub_match object representing the
1925  * part of the target range between the end of the match and the end of
1926  * the target range.
1927  */
1928  const_reference
1929  suffix() const
1930  {
1931  __glibcxx_assert( ready() );
1932  return !empty() ? _M_suffix() : _M_unmatched_sub();
1933  }
1934 
1935  /**
1936  * @brief Gets an iterator to the start of the %sub_match collection.
1937  */
1938  const_iterator
1939  begin() const noexcept
1940  { return _Base_type::begin(); }
1941 
1942  /**
1943  * @brief Gets an iterator to the start of the %sub_match collection.
1944  */
1945  const_iterator
1946  cbegin() const noexcept
1947  { return this->begin(); }
1948 
1949  /**
1950  * @brief Gets an iterator to one-past-the-end of the collection.
1951  */
1952  const_iterator
1953  end() const noexcept
1954  { return _Base_type::end() - (_Base_type::empty() ? 0 : 3); }
1955 
1956  /**
1957  * @brief Gets an iterator to one-past-the-end of the collection.
1958  */
1959  const_iterator
1960  cend() const noexcept
1961  { return this->end(); }
1962 
1963  ///@}
1964 
1965  /**
1966  * @name 28.10.5 Formatting
1967  *
1968  * These functions perform formatted substitution of the matched
1969  * character sequences into their target. The format specifiers and
1970  * escape sequences accepted by these functions are determined by
1971  * their @p flags parameter as documented above.
1972  */
1973  ///@{
1974 
1975  /**
1976  * @pre ready() == true
1977  */
1978  template<typename _Out_iter>
1979  _Out_iter
1980  format(_Out_iter __out, const char_type* __fmt_first,
1981  const char_type* __fmt_last,
1983 
1984  /**
1985  * @pre ready() == true
1986  */
1987  template<typename _Out_iter, typename _St, typename _Sa>
1988  _Out_iter
1989  format(_Out_iter __out, const basic_string<char_type, _St, _Sa>& __fmt,
1991  {
1992  return format(__out, __fmt.data(), __fmt.data() + __fmt.size(),
1993  __flags);
1994  }
1995 
1996  /**
1997  * @pre ready() == true
1998  */
1999  template<typename _St, typename _Sa>
2003  {
2005  format(std::back_inserter(__result), __fmt, __flags);
2006  return __result;
2007  }
2008 
2009  /**
2010  * @pre ready() == true
2011  */
2012  string_type
2013  format(const char_type* __fmt,
2015  {
2016  string_type __result;
2017  format(std::back_inserter(__result),
2018  __fmt,
2019  __fmt + char_traits<char_type>::length(__fmt),
2020  __flags);
2021  return __result;
2022  }
2023 
2024  ///@}
2025 
2026  /**
2027  * @name 28.10.6 Allocator
2028  */
2029  ///@{
2030 
2031  /**
2032  * @brief Gets a copy of the allocator.
2033  */
2034  allocator_type
2035  get_allocator() const noexcept
2036  { return _Base_type::get_allocator(); }
2037 
2038  ///@}
2039 
2040  /**
2041  * @name 28.10.7 Swap
2042  */
2043  ///@{
2044 
2045  /**
2046  * @brief Swaps the contents of two match_results.
2047  */
2048  void
2049  swap(match_results& __that) noexcept
2050  {
2051  using std::swap;
2052  _Base_type::swap(__that);
2053  swap(_M_begin, __that._M_begin);
2054  }
2055  ///@}
2056 
2057  private:
2058  template<typename, typename, typename>
2059  friend class regex_iterator;
2060 
2061  /// @cond undocumented
2062 
2063  template<typename, typename, typename, bool>
2064  friend class __detail::_Executor;
2065 
2066  template<typename _Bp, typename _Ap, typename _Cp, typename _Rp,
2067  __detail::_RegexExecutorPolicy, bool>
2068  friend bool
2069  __detail::__regex_algo_impl(_Bp, _Bp, match_results<_Bp, _Ap>&,
2070  const basic_regex<_Cp, _Rp>&,
2072 
2073  // Reset contents to __size unmatched sub_match objects
2074  // (plus additional objects for prefix, suffix and unmatched sub).
2075  void
2076  _M_resize(unsigned int __size)
2077  { _Unchecked::assign(__size + 3, sub_match<_Bi_iter>{}); }
2078 
2079  // Set state to a failed match for the given past-the-end iterator.
2080  void
2081  _M_establish_failed_match(_Bi_iter __end)
2082  {
2083  sub_match<_Bi_iter> __sm;
2084  __sm.first = __sm.second = __end;
2085  _Unchecked::assign(3, __sm);
2086  }
2087 
2088  const_reference
2089  _M_unmatched_sub() const
2090  { return _Unchecked::operator[](_Unchecked::size() - 3); }
2091 
2092  sub_match<_Bi_iter>&
2093  _M_unmatched_sub()
2094  { return _Unchecked::operator[](_Unchecked::size() - 3); }
2095 
2096  const_reference
2097  _M_prefix() const
2098  { return _Unchecked::operator[](_Unchecked::size() - 2); }
2099 
2100  sub_match<_Bi_iter>&
2101  _M_prefix()
2102  { return _Unchecked::operator[](_Unchecked::size() - 2); }
2103 
2104  const_reference
2105  _M_suffix() const
2106  { return _Unchecked::operator[](_Unchecked::size() - 1); }
2107 
2108  sub_match<_Bi_iter>&
2109  _M_suffix()
2110  { return _Unchecked::operator[](_Unchecked::size() - 1); }
2111 
2112  _Bi_iter _M_begin;
2113  /// @endcond
2114  };
2115 
2116  typedef match_results<const char*> cmatch;
2117  typedef match_results<string::const_iterator> smatch;
2118 #ifdef _GLIBCXX_USE_WCHAR_T
2119  typedef match_results<const wchar_t*> wcmatch;
2120  typedef match_results<wstring::const_iterator> wsmatch;
2121 #endif
2122 
2123  // match_results comparisons
2124 
2125  /**
2126  * @brief Compares two match_results for equality.
2127  * @returns true if the two objects refer to the same match,
2128  * false otherwise.
2129  */
2130  template<typename _Bi_iter, typename _Alloc>
2131  inline bool
2133  const match_results<_Bi_iter, _Alloc>& __m2)
2134  {
2135  if (__m1.ready() != __m2.ready())
2136  return false;
2137  if (!__m1.ready()) // both are not ready
2138  return true;
2139  if (__m1.empty() != __m2.empty())
2140  return false;
2141  if (__m1.empty()) // both are empty
2142  return true;
2143  return __m1.prefix() == __m2.prefix()
2144  && __m1.size() == __m2.size()
2145  && std::equal(__m1.begin(), __m1.end(), __m2.begin())
2146  && __m1.suffix() == __m2.suffix();
2147  }
2148 
2149 #if ! __cpp_lib_three_way_comparison
2150  /**
2151  * @brief Compares two match_results for inequality.
2152  * @returns true if the two objects do not refer to the same match,
2153  * false otherwise.
2154  */
2155  template<typename _Bi_iter, class _Alloc>
2156  inline bool
2158  const match_results<_Bi_iter, _Alloc>& __m2)
2159  { return !(__m1 == __m2); }
2160 #endif
2161 
2162  // [7.10.6] match_results swap
2163  /**
2164  * @brief Swaps two match results.
2165  * @param __lhs A match result.
2166  * @param __rhs A match result.
2167  *
2168  * The contents of the two match_results objects are swapped.
2169  */
2170  template<typename _Bi_iter, typename _Alloc>
2171  inline void
2173  match_results<_Bi_iter, _Alloc>& __rhs) noexcept
2174  { __lhs.swap(__rhs); }
2175 
2176 _GLIBCXX_END_NAMESPACE_CXX11
2177 
2178  // [28.11.2] Function template regex_match
2179  /**
2180  * @name Matching, Searching, and Replacing
2181  */
2182  ///@{
2183 
2184  /**
2185  * @brief Determines if there is a match between the regular expression @p e
2186  * and all of the character sequence [first, last).
2187  *
2188  * @param __s Start of the character sequence to match.
2189  * @param __e One-past-the-end of the character sequence to match.
2190  * @param __m The match results.
2191  * @param __re The regular expression.
2192  * @param __flags Controls how the regular expression is matched.
2193  *
2194  * @retval true A match exists.
2195  * @retval false Otherwise.
2196  *
2197  * @throws an exception of type regex_error.
2198  */
2199  template<typename _Bi_iter, typename _Alloc,
2200  typename _Ch_type, typename _Rx_traits>
2201  inline bool
2202  regex_match(_Bi_iter __s,
2203  _Bi_iter __e,
2208  {
2209  return __detail::__regex_algo_impl<_Bi_iter, _Alloc, _Ch_type, _Rx_traits,
2210  __detail::_RegexExecutorPolicy::_S_auto, true>
2211  (__s, __e, __m, __re, __flags);
2212  }
2213 
2214  /**
2215  * @brief Indicates if there is a match between the regular expression @p e
2216  * and all of the character sequence [first, last).
2217  *
2218  * @param __first Beginning of the character sequence to match.
2219  * @param __last One-past-the-end of the character sequence to match.
2220  * @param __re The regular expression.
2221  * @param __flags Controls how the regular expression is matched.
2222  *
2223  * @retval true A match exists.
2224  * @retval false Otherwise.
2225  *
2226  * @throws an exception of type regex_error.
2227  */
2228  template<typename _Bi_iter, typename _Ch_type, typename _Rx_traits>
2229  inline bool
2230  regex_match(_Bi_iter __first, _Bi_iter __last,
2234  {
2235  match_results<_Bi_iter> __what;
2236  return regex_match(__first, __last, __what, __re, __flags);
2237  }
2238 
2239  /**
2240  * @brief Determines if there is a match between the regular expression @p e
2241  * and a C-style null-terminated string.
2242  *
2243  * @param __s The C-style null-terminated string to match.
2244  * @param __m The match results.
2245  * @param __re The regular expression.
2246  * @param __f Controls how the regular expression is matched.
2247  *
2248  * @retval true A match exists.
2249  * @retval false Otherwise.
2250  *
2251  * @throws an exception of type regex_error.
2252  */
2253  template<typename _Ch_type, typename _Alloc, typename _Rx_traits>
2254  inline bool
2255  regex_match(const _Ch_type* __s,
2260  { return regex_match(__s, __s + _Rx_traits::length(__s), __m, __re, __f); }
2261 
2262  /**
2263  * @brief Determines if there is a match between the regular expression @p e
2264  * and a string.
2265  *
2266  * @param __s The string to match.
2267  * @param __m The match results.
2268  * @param __re The regular expression.
2269  * @param __flags Controls how the regular expression is matched.
2270  *
2271  * @retval true A match exists.
2272  * @retval false Otherwise.
2273  *
2274  * @throws an exception of type regex_error.
2275  */
2276  template<typename _Ch_traits, typename _Ch_alloc,
2277  typename _Alloc, typename _Ch_type, typename _Rx_traits>
2278  inline bool
2280  match_results<typename basic_string<_Ch_type,
2281  _Ch_traits, _Ch_alloc>::const_iterator, _Alloc>& __m,
2285  { return regex_match(__s.begin(), __s.end(), __m, __re, __flags); }
2286 
2287  // _GLIBCXX_RESOLVE_LIB_DEFECTS
2288  // 2329. regex_match() with match_results should forbid temporary strings
2289  /// Prevent unsafe attempts to get match_results from a temporary string.
2290  template<typename _Ch_traits, typename _Ch_alloc,
2291  typename _Alloc, typename _Ch_type, typename _Rx_traits>
2292  bool
2294  match_results<typename basic_string<_Ch_type,
2295  _Ch_traits, _Ch_alloc>::const_iterator, _Alloc>&,
2298  = regex_constants::match_default) = delete;
2299 
2300  /**
2301  * @brief Indicates if there is a match between the regular expression @p e
2302  * and a C-style null-terminated string.
2303  *
2304  * @param __s The C-style null-terminated string to match.
2305  * @param __re The regular expression.
2306  * @param __f Controls how the regular expression is matched.
2307  *
2308  * @retval true A match exists.
2309  * @retval false Otherwise.
2310  *
2311  * @throws an exception of type regex_error.
2312  */
2313  template<typename _Ch_type, class _Rx_traits>
2314  inline bool
2315  regex_match(const _Ch_type* __s,
2319  { return regex_match(__s, __s + _Rx_traits::length(__s), __re, __f); }
2320 
2321  /**
2322  * @brief Indicates if there is a match between the regular expression @p e
2323  * and a string.
2324  *
2325  * @param __s [IN] The string to match.
2326  * @param __re [IN] The regular expression.
2327  * @param __flags [IN] Controls how the regular expression is matched.
2328  *
2329  * @retval true A match exists.
2330  * @retval false Otherwise.
2331  *
2332  * @throws an exception of type regex_error.
2333  */
2334  template<typename _Ch_traits, typename _Str_allocator,
2335  typename _Ch_type, typename _Rx_traits>
2336  inline bool
2341  { return regex_match(__s.begin(), __s.end(), __re, __flags); }
2342 
2343  // [7.11.3] Function template regex_search
2344  /**
2345  * Searches for a regular expression within a range.
2346  * @param __s [IN] The start of the string to search.
2347  * @param __e [IN] One-past-the-end of the string to search.
2348  * @param __m [OUT] The match results.
2349  * @param __re [IN] The regular expression to search for.
2350  * @param __flags [IN] Search policy flags.
2351  * @retval true A match was found within the string.
2352  * @retval false No match was found within the string, the content of %m is
2353  * undefined.
2354  *
2355  * @throws an exception of type regex_error.
2356  */
2357  template<typename _Bi_iter, typename _Alloc,
2358  typename _Ch_type, typename _Rx_traits>
2359  inline bool
2360  regex_search(_Bi_iter __s, _Bi_iter __e,
2365  {
2366  return __detail::__regex_algo_impl<_Bi_iter, _Alloc, _Ch_type, _Rx_traits,
2367  __detail::_RegexExecutorPolicy::_S_auto, false>
2368  (__s, __e, __m, __re, __flags);
2369  }
2370 
2371  /**
2372  * Searches for a regular expression within a range.
2373  * @param __first [IN] The start of the string to search.
2374  * @param __last [IN] One-past-the-end of the string to search.
2375  * @param __re [IN] The regular expression to search for.
2376  * @param __flags [IN] Search policy flags.
2377  * @retval true A match was found within the string.
2378  * @retval false No match was found within the string.
2379  *
2380  * @throws an exception of type regex_error.
2381  */
2382  template<typename _Bi_iter, typename _Ch_type, typename _Rx_traits>
2383  inline bool
2384  regex_search(_Bi_iter __first, _Bi_iter __last,
2388  {
2389  match_results<_Bi_iter> __what;
2390  return regex_search(__first, __last, __what, __re, __flags);
2391  }
2392 
2393  /**
2394  * @brief Searches for a regular expression within a C-string.
2395  * @param __s [IN] A C-string to search for the regex.
2396  * @param __m [OUT] The set of regex matches.
2397  * @param __e [IN] The regex to search for in @p s.
2398  * @param __f [IN] The search flags.
2399  * @retval true A match was found within the string.
2400  * @retval false No match was found within the string, the content of %m is
2401  * undefined.
2402  *
2403  * @throws an exception of type regex_error.
2404  */
2405  template<typename _Ch_type, class _Alloc, class _Rx_traits>
2406  inline bool
2407  regex_search(const _Ch_type* __s,
2412  { return regex_search(__s, __s + _Rx_traits::length(__s), __m, __e, __f); }
2413 
2414  /**
2415  * @brief Searches for a regular expression within a C-string.
2416  * @param __s [IN] The C-string to search.
2417  * @param __e [IN] The regular expression to search for.
2418  * @param __f [IN] Search policy flags.
2419  * @retval true A match was found within the string.
2420  * @retval false No match was found within the string.
2421  *
2422  * @throws an exception of type regex_error.
2423  */
2424  template<typename _Ch_type, typename _Rx_traits>
2425  inline bool
2426  regex_search(const _Ch_type* __s,
2430  { return regex_search(__s, __s + _Rx_traits::length(__s), __e, __f); }
2431 
2432  /**
2433  * @brief Searches for a regular expression within a string.
2434  * @param __s [IN] The string to search.
2435  * @param __e [IN] The regular expression to search for.
2436  * @param __flags [IN] Search policy flags.
2437  * @retval true A match was found within the string.
2438  * @retval false No match was found within the string.
2439  *
2440  * @throws an exception of type regex_error.
2441  */
2442  template<typename _Ch_traits, typename _String_allocator,
2443  typename _Ch_type, typename _Rx_traits>
2444  inline bool
2445  regex_search(const basic_string<_Ch_type, _Ch_traits,
2446  _String_allocator>& __s,
2450  { return regex_search(__s.begin(), __s.end(), __e, __flags); }
2451 
2452  /**
2453  * @brief Searches for a regular expression within a string.
2454  * @param __s [IN] A C++ string to search for the regex.
2455  * @param __m [OUT] The set of regex matches.
2456  * @param __e [IN] The regex to search for in @p s.
2457  * @param __f [IN] The search flags.
2458  * @retval true A match was found within the string.
2459  * @retval false No match was found within the string, the content of %m is
2460  * undefined.
2461  *
2462  * @throws an exception of type regex_error.
2463  */
2464  template<typename _Ch_traits, typename _Ch_alloc,
2465  typename _Alloc, typename _Ch_type,
2466  typename _Rx_traits>
2467  inline bool
2469  match_results<typename basic_string<_Ch_type,
2470  _Ch_traits, _Ch_alloc>::const_iterator, _Alloc>& __m,
2474  { return regex_search(__s.begin(), __s.end(), __m, __e, __f); }
2475 
2476  // _GLIBCXX_RESOLVE_LIB_DEFECTS
2477  // 2329. regex_search() with match_results should forbid temporary strings
2478  /// Prevent unsafe attempts to get match_results from a temporary string.
2479  template<typename _Ch_traits, typename _Ch_alloc,
2480  typename _Alloc, typename _Ch_type,
2481  typename _Rx_traits>
2482  bool
2484  match_results<typename basic_string<_Ch_type,
2485  _Ch_traits, _Ch_alloc>::const_iterator, _Alloc>&,
2488  = regex_constants::match_default) = delete;
2489 
2490  // std [28.11.4] Function template regex_replace
2491  /**
2492  * @brief Search for a regular expression within a range for multiple times,
2493  and replace the matched parts through filling a format string.
2494  * @param __out [OUT] The output iterator.
2495  * @param __first [IN] The start of the string to search.
2496  * @param __last [IN] One-past-the-end of the string to search.
2497  * @param __e [IN] The regular expression to search for.
2498  * @param __fmt [IN] The format string.
2499  * @param __flags [IN] Search and replace policy flags.
2500  *
2501  * @returns __out
2502  * @throws an exception of type regex_error.
2503  */
2504  template<typename _Out_iter, typename _Bi_iter,
2505  typename _Rx_traits, typename _Ch_type,
2506  typename _St, typename _Sa>
2507  inline _Out_iter
2508  regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
2510  const basic_string<_Ch_type, _St, _Sa>& __fmt,
2513  {
2514  return regex_replace(__out, __first, __last, __e, __fmt.c_str(), __flags);
2515  }
2516 
2517  /**
2518  * @brief Search for a regular expression within a range for multiple times,
2519  and replace the matched parts through filling a format C-string.
2520  * @param __out [OUT] The output iterator.
2521  * @param __first [IN] The start of the string to search.
2522  * @param __last [IN] One-past-the-end of the string to search.
2523  * @param __e [IN] The regular expression to search for.
2524  * @param __fmt [IN] The format C-string.
2525  * @param __flags [IN] Search and replace policy flags.
2526  *
2527  * @returns __out
2528  * @throws an exception of type regex_error.
2529  */
2530  template<typename _Out_iter, typename _Bi_iter,
2531  typename _Rx_traits, typename _Ch_type>
2532  _Out_iter
2533  regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
2535  const _Ch_type* __fmt,
2538 
2539  /**
2540  * @brief Search for a regular expression within a string for multiple times,
2541  and replace the matched parts through filling a format string.
2542  * @param __s [IN] The string to search and replace.
2543  * @param __e [IN] The regular expression to search for.
2544  * @param __fmt [IN] The format string.
2545  * @param __flags [IN] Search and replace policy flags.
2546  *
2547  * @returns The string after replacing.
2548  * @throws an exception of type regex_error.
2549  */
2550  template<typename _Rx_traits, typename _Ch_type,
2551  typename _St, typename _Sa, typename _Fst, typename _Fsa>
2558  {
2561  __s.begin(), __s.end(), __e, __fmt, __flags);
2562  return __result;
2563  }
2564 
2565  /**
2566  * @brief Search for a regular expression within a string for multiple times,
2567  and replace the matched parts through filling a format C-string.
2568  * @param __s [IN] The string to search and replace.
2569  * @param __e [IN] The regular expression to search for.
2570  * @param __fmt [IN] The format C-string.
2571  * @param __flags [IN] Search and replace policy flags.
2572  *
2573  * @returns The string after replacing.
2574  * @throws an exception of type regex_error.
2575  */
2576  template<typename _Rx_traits, typename _Ch_type,
2577  typename _St, typename _Sa>
2578  inline basic_string<_Ch_type, _St, _Sa>
2581  const _Ch_type* __fmt,
2584  {
2587  __s.begin(), __s.end(), __e, __fmt, __flags);
2588  return __result;
2589  }
2590 
2591  /**
2592  * @brief Search for a regular expression within a C-string for multiple
2593  times, and replace the matched parts through filling a format string.
2594  * @param __s [IN] The C-string to search and replace.
2595  * @param __e [IN] The regular expression to search for.
2596  * @param __fmt [IN] The format string.
2597  * @param __flags [IN] Search and replace policy flags.
2598  *
2599  * @returns The string after replacing.
2600  * @throws an exception of type regex_error.
2601  */
2602  template<typename _Rx_traits, typename _Ch_type,
2603  typename _St, typename _Sa>
2604  inline basic_string<_Ch_type>
2605  regex_replace(const _Ch_type* __s,
2607  const basic_string<_Ch_type, _St, _Sa>& __fmt,
2610  {
2611  basic_string<_Ch_type> __result;
2612  regex_replace(std::back_inserter(__result), __s,
2613  __s + char_traits<_Ch_type>::length(__s),
2614  __e, __fmt, __flags);
2615  return __result;
2616  }
2617 
2618  /**
2619  * @brief Search for a regular expression within a C-string for multiple
2620  times, and replace the matched parts through filling a format C-string.
2621  * @param __s [IN] The C-string to search and replace.
2622  * @param __e [IN] The regular expression to search for.
2623  * @param __fmt [IN] The format C-string.
2624  * @param __flags [IN] Search and replace policy flags.
2625  *
2626  * @returns The string after replacing.
2627  * @throws an exception of type regex_error.
2628  */
2629  template<typename _Rx_traits, typename _Ch_type>
2630  inline basic_string<_Ch_type>
2631  regex_replace(const _Ch_type* __s,
2633  const _Ch_type* __fmt,
2636  {
2637  basic_string<_Ch_type> __result;
2638  regex_replace(std::back_inserter(__result), __s,
2639  __s + char_traits<_Ch_type>::length(__s),
2640  __e, __fmt, __flags);
2641  return __result;
2642  }
2643 
2644  ///@}
2645 
2646 _GLIBCXX_BEGIN_NAMESPACE_CXX11
2647 
2648  // std [28.12] Class template regex_iterator
2649  /**
2650  * An iterator adaptor that will provide repeated calls of regex_search over
2651  * a range until no more matches remain.
2652  */
2653  template<typename _Bi_iter,
2654  typename _Ch_type = typename iterator_traits<_Bi_iter>::value_type,
2655  typename _Rx_traits = regex_traits<_Ch_type> >
2657  {
2658  public:
2660  typedef match_results<_Bi_iter> value_type;
2661  typedef std::ptrdiff_t difference_type;
2662  typedef const value_type* pointer;
2663  typedef const value_type& reference;
2665 
2666  /**
2667  * @brief Provides a singular iterator, useful for indicating
2668  * one-past-the-end of a range.
2669  */
2670  regex_iterator() = default;
2671 
2672  /**
2673  * Constructs a %regex_iterator...
2674  * @param __a [IN] The start of a text range to search.
2675  * @param __b [IN] One-past-the-end of the text range to search.
2676  * @param __re [IN] The regular expression to match.
2677  * @param __m [IN] Policy flags for match rules.
2678  */
2679  regex_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type& __re,
2682  : _M_begin(__a), _M_end(__b), _M_pregex(&__re), _M_flags(__m), _M_match()
2683  {
2684  if (!regex_search(_M_begin, _M_end, _M_match, *_M_pregex, _M_flags))
2685  *this = regex_iterator();
2686  }
2687 
2688  // _GLIBCXX_RESOLVE_LIB_DEFECTS
2689  // 2332. regex_iterator should forbid temporary regexes
2690  regex_iterator(_Bi_iter, _Bi_iter, const regex_type&&,
2692  = regex_constants::match_default) = delete;
2693 
2694  /// Copy constructs a %regex_iterator.
2695  regex_iterator(const regex_iterator&) = default;
2696 
2697  /// Copy assigns one %regex_iterator to another.
2699  operator=(const regex_iterator&) = default;
2700 
2701  ~regex_iterator() = default;
2702 
2703  /**
2704  * @brief Tests the equivalence of two regex iterators.
2705  */
2706  bool
2707  operator==(const regex_iterator&) const noexcept;
2708 
2709  /**
2710  * @brief Tests the inequivalence of two regex iterators.
2711  */
2712  bool
2713  operator!=(const regex_iterator& __rhs) const noexcept
2714  { return !(*this == __rhs); }
2715 
2716  /**
2717  * @brief Dereferences a %regex_iterator.
2718  */
2719  const value_type&
2720  operator*() const noexcept
2721  { return _M_match; }
2722 
2723  /**
2724  * @brief Selects a %regex_iterator member.
2725  */
2726  const value_type*
2727  operator->() const noexcept
2728  { return &_M_match; }
2729 
2730  /**
2731  * @brief Increments a %regex_iterator.
2732  */
2735 
2736  /**
2737  * @brief Postincrements a %regex_iterator.
2738  */
2741  {
2742  auto __tmp = *this;
2743  ++(*this);
2744  return __tmp;
2745  }
2746 
2747  private:
2748  _Bi_iter _M_begin {};
2749  _Bi_iter _M_end {};
2750  const regex_type* _M_pregex = nullptr;
2752  match_results<_Bi_iter> _M_match;
2753  };
2754 
2755  typedef regex_iterator<const char*> cregex_iterator;
2756  typedef regex_iterator<string::const_iterator> sregex_iterator;
2757 #ifdef _GLIBCXX_USE_WCHAR_T
2758  typedef regex_iterator<const wchar_t*> wcregex_iterator;
2759  typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
2760 #endif
2761 
2762  // [7.12.2] Class template regex_token_iterator
2763  /**
2764  * Iterates over submatches in a range (or @a splits a text string).
2765  *
2766  * The purpose of this iterator is to enumerate all, or all specified,
2767  * matches of a regular expression within a text range. The dereferenced
2768  * value of an iterator of this class is a std::sub_match object.
2769  */
2770  template<typename _Bi_iter,
2771  typename _Ch_type = typename iterator_traits<_Bi_iter>::value_type,
2772  typename _Rx_traits = regex_traits<_Ch_type> >
2774  {
2775  public:
2778  typedef std::ptrdiff_t difference_type;
2779  typedef const value_type* pointer;
2780  typedef const value_type& reference;
2782 
2783  public:
2784  /**
2785  * @brief Default constructs a %regex_token_iterator.
2786  *
2787  * A default-constructed %regex_token_iterator is a singular iterator
2788  * that will compare equal to the one-past-the-end value for any
2789  * iterator of the same type.
2790  */
2792  : _M_position(), _M_subs(), _M_suffix(), _M_n(0), _M_result(nullptr),
2793  _M_has_m1(false)
2794  { }
2795 
2796  /**
2797  * Constructs a %regex_token_iterator...
2798  * @param __a [IN] The start of the text to search.
2799  * @param __b [IN] One-past-the-end of the text to search.
2800  * @param __re [IN] The regular expression to search for.
2801  * @param __submatch [IN] Which submatch to return. There are some
2802  * special values for this parameter:
2803  * - -1 each enumerated subexpression does NOT
2804  * match the regular expression (aka field
2805  * splitting)
2806  * - 0 the entire string matching the
2807  * subexpression is returned for each match
2808  * within the text.
2809  * - >0 enumerates only the indicated
2810  * subexpression from a match within the text.
2811  * @param __m [IN] Policy flags for match rules.
2812  */
2813  regex_token_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type& __re,
2814  int __submatch = 0,
2817  : _M_position(__a, __b, __re, __m), _M_subs(1, __submatch), _M_n(0)
2818  { _M_init(__a, __b); }
2819 
2820  /**
2821  * Constructs a %regex_token_iterator...
2822  * @param __a [IN] The start of the text to search.
2823  * @param __b [IN] One-past-the-end of the text to search.
2824  * @param __re [IN] The regular expression to search for.
2825  * @param __submatches [IN] A list of subexpressions to return for each
2826  * regular expression match within the text.
2827  * @param __m [IN] Policy flags for match rules.
2828  */
2829  regex_token_iterator(_Bi_iter __a, _Bi_iter __b,
2830  const regex_type& __re,
2831  const std::vector<int>& __submatches,
2834  : _M_position(__a, __b, __re, __m), _M_subs(__submatches), _M_n(0)
2835  { _M_init(__a, __b); }
2836 
2837  /**
2838  * Constructs a %regex_token_iterator...
2839  * @param __a [IN] The start of the text to search.
2840  * @param __b [IN] One-past-the-end of the text to search.
2841  * @param __re [IN] The regular expression to search for.
2842  * @param __submatches [IN] A list of subexpressions to return for each
2843  * regular expression match within the text.
2844  * @param __m [IN] Policy flags for match rules.
2845  */
2846  regex_token_iterator(_Bi_iter __a, _Bi_iter __b,
2847  const regex_type& __re,
2848  initializer_list<int> __submatches,
2851  : _M_position(__a, __b, __re, __m), _M_subs(__submatches), _M_n(0)
2852  { _M_init(__a, __b); }
2853 
2854  /**
2855  * Constructs a %regex_token_iterator...
2856  * @param __a [IN] The start of the text to search.
2857  * @param __b [IN] One-past-the-end of the text to search.
2858  * @param __re [IN] The regular expression to search for.
2859  * @param __submatches [IN] A list of subexpressions to return for each
2860  * regular expression match within the text.
2861  * @param __m [IN] Policy flags for match rules.
2862  */
2863  template<std::size_t _Nm>
2864  regex_token_iterator(_Bi_iter __a, _Bi_iter __b,
2865  const regex_type& __re,
2866  const int (&__submatches)[_Nm],
2869  : _M_position(__a, __b, __re, __m),
2870  _M_subs(__submatches, __submatches + _Nm), _M_n(0)
2871  { _M_init(__a, __b); }
2872 
2873  // _GLIBCXX_RESOLVE_LIB_DEFECTS
2874  // 2332. regex_token_iterator should forbid temporary regexes
2875  regex_token_iterator(_Bi_iter, _Bi_iter, const regex_type&&, int = 0,
2878  regex_token_iterator(_Bi_iter, _Bi_iter, const regex_type&&,
2879  const std::vector<int>&,
2882  regex_token_iterator(_Bi_iter, _Bi_iter, const regex_type&&,
2886  template <std::size_t _Nm>
2887  regex_token_iterator(_Bi_iter, _Bi_iter, const regex_type&&,
2888  const int (&)[_Nm],
2891 
2892  /**
2893  * @brief Copy constructs a %regex_token_iterator.
2894  * @param __rhs [IN] A %regex_token_iterator to copy.
2895  */
2897  : _M_position(__rhs._M_position), _M_subs(__rhs._M_subs),
2898  _M_suffix(__rhs._M_suffix), _M_n(__rhs._M_n), _M_has_m1(__rhs._M_has_m1)
2899  { _M_normalize_result(); }
2900 
2901  /**
2902  * @brief Assigns a %regex_token_iterator to another.
2903  * @param __rhs [IN] A %regex_token_iterator to copy.
2904  */
2907 
2908  /**
2909  * @brief Compares a %regex_token_iterator to another for equality.
2910  */
2911  bool
2912  operator==(const regex_token_iterator& __rhs) const;
2913 
2914  /**
2915  * @brief Compares a %regex_token_iterator to another for inequality.
2916  */
2917  bool
2918  operator!=(const regex_token_iterator& __rhs) const
2919  { return !(*this == __rhs); }
2920 
2921  /**
2922  * @brief Dereferences a %regex_token_iterator.
2923  */
2924  const value_type&
2925  operator*() const
2926  { return *_M_result; }
2927 
2928  /**
2929  * @brief Selects a %regex_token_iterator member.
2930  */
2931  const value_type*
2932  operator->() const
2933  { return _M_result; }
2934 
2935  /**
2936  * @brief Increments a %regex_token_iterator.
2937  */
2940 
2941  /**
2942  * @brief Postincrements a %regex_token_iterator.
2943  */
2946  {
2947  auto __tmp = *this;
2948  ++(*this);
2949  return __tmp;
2950  }
2951 
2952  private:
2954 
2955  void
2956  _M_init(_Bi_iter __a, _Bi_iter __b);
2957 
2958  const value_type&
2959  _M_current_match() const
2960  {
2961  if (_M_subs[_M_n] == -1)
2962  return (*_M_position).prefix();
2963  else
2964  return (*_M_position)[_M_subs[_M_n]];
2965  }
2966 
2967  constexpr bool
2968  _M_end_of_seq() const
2969  { return _M_result == nullptr; }
2970 
2971  // [28.12.2.2.4]
2972  void
2973  _M_normalize_result()
2974  {
2975  if (_M_position != _Position())
2976  _M_result = &_M_current_match();
2977  else if (_M_has_m1)
2978  _M_result = &_M_suffix;
2979  else
2980  _M_result = nullptr;
2981  }
2982 
2983  _Position _M_position;
2984  std::vector<int> _M_subs;
2985  value_type _M_suffix;
2986  std::size_t _M_n;
2987  const value_type* _M_result;
2988 
2989  // Show whether _M_subs contains -1
2990  bool _M_has_m1;
2991  };
2992 
2993  /** @brief Token iterator for C-style NULL-terminated strings. */
2995 
2996  /** @brief Token iterator for standard strings. */
2998 
2999 #ifdef _GLIBCXX_USE_WCHAR_T
3000  /** @brief Token iterator for C-style NULL-terminated wide strings. */
3002 
3003  /** @brief Token iterator for standard wide-character strings. */
3005 #endif
3006 
3007  ///@} // group regex
3008 
3009 _GLIBCXX_END_NAMESPACE_CXX11
3010 _GLIBCXX_END_NAMESPACE_VERSION
3011 } // namespace
3012 
3013 #include <bits/regex.tcc>
integral_constant< bool, true > true_type
The type used as a compile-time boolean with true value.
Definition: type_traits:82
integral_constant< bool, false > false_type
The type used as a compile-time boolean with false value.
Definition: type_traits:85
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
Definition: move.h:49
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
Definition: move.h:104
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
Definition: any:429
constexpr const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
Definition: stl_algobase.h:230
bool operator>=(typename iterator_traits< _Bi_iter >::value_type const &__lhs, const sub_match< _Bi_iter > &__rhs)
Tests the ordering of a character and a regular expression submatch.
Definition: regex.h:1547
sub_match< wstring::const_iterator > wssub_match
Regex submatch over a standard wide string.
Definition: regex.h:1049
bool operator!=(const sub_match< _Bi_iter > &__lhs, typename iterator_traits< _Bi_iter >::value_type const &__rhs)
Tests the inequivalence of a regular expression submatch and a character.
Definition: regex.h:1608
sub_match< string::const_iterator > ssub_match
Standard regex submatch over a standard string.
Definition: regex.h:1042
bool operator==(const __sub_match_string< _Bi_iter, _Ch_traits, _Ch_alloc > &__lhs, const sub_match< _Bi_iter > &__rhs)
Tests the equivalence of a string and a regular expression submatch.
Definition: regex.h:1160
bool operator!=(const __sub_match_string< _Bi_iter, _Ch_traits, _Ch_alloc > &__lhs, const sub_match< _Bi_iter > &__rhs)
Tests the inequivalence of a string and a regular expression submatch.
Definition: regex.h:1173
sub_match< const char * > csub_match
Standard regex submatch over a C-style null-terminated string.
Definition: regex.h:1039
regex_token_iterator< const char * > cregex_token_iterator
Token iterator for C-style NULL-terminated strings.
Definition: regex.h:2994
bool operator==(const sub_match< _Bi_iter > &__lhs, const __sub_match_string< _Bi_iter, _Ch_traits, _Ch_alloc > &__rhs)
Tests the equivalence of a regular expression submatch and a string.
Definition: regex.h:1235
bool operator>=(const __sub_match_string< _Bi_iter, _Ch_traits, _Ch_alloc > &__lhs, const sub_match< _Bi_iter > &__rhs)
Tests the ordering of a string and a regular expression submatch.
Definition: regex.h:1209
regex_token_iterator< wstring::const_iterator > wsregex_token_iterator
Token iterator for standard wide-character strings.
Definition: regex.h:3004
bool operator==(const sub_match< _Bi_iter > &__lhs, typename iterator_traits< _Bi_iter >::value_type const &__rhs)
Tests the equivalence of a regular expression submatch and a character.
Definition: regex.h:1574
bool operator>=(const sub_match< _Bi_iter > &__lhs, typename iterator_traits< _Bi_iter >::value_type const *__rhs)
Tests the ordering of a regular expression submatch and a C string.
Definition: regex.h:1470
bool operator==(const sub_match< _Bi_iter > &__lhs, typename iterator_traits< _Bi_iter >::value_type const *__rhs)
Tests the equivalence of a regular expression submatch and a C string.
Definition: regex.h:1402
bool operator!=(const sub_match< _Bi_iter > &__lhs, typename iterator_traits< _Bi_iter >::value_type const *__rhs)
Tests the inequivalence of a regular expression submatch and a string.
Definition: regex.h:1434
bool operator!=(typename iterator_traits< _Bi_iter >::value_type const *__lhs, const sub_match< _Bi_iter > &__rhs)
Tests the inequivalence of a C string and a regular expression submatch.
Definition: regex.h:1340
regex_token_iterator< const wchar_t * > wcregex_token_iterator
Token iterator for C-style NULL-terminated wide strings.
Definition: regex.h:3001
void swap(basic_regex< _Ch_type, _Rx_traits > &__lhs, basic_regex< _Ch_type, _Rx_traits > &__rhs) noexcept
Swaps the contents of two regular expression objects.
Definition: regex.h:877
bool operator>(const sub_match< _Bi_iter > &__lhs, typename iterator_traits< _Bi_iter >::value_type const &__rhs)
Tests the ordering of a regular expression submatch and a character.
Definition: regex.h:1634
bool operator>(const sub_match< _Bi_iter > &__lhs, typename iterator_traits< _Bi_iter >::value_type const *__rhs)
Tests the ordering of a regular expression submatch and a C string.
Definition: regex.h:1458
bool operator>=(const sub_match< _Bi_iter > &__lhs, typename iterator_traits< _Bi_iter >::value_type const &__rhs)
Tests the ordering of a regular expression submatch and a character.
Definition: regex.h:1647
bool operator>(typename iterator_traits< _Bi_iter >::value_type const &__lhs, const sub_match< _Bi_iter > &__rhs)
Tests the ordering of a character and a regular expression submatch.
Definition: regex.h:1534
basic_regex< char > regex
Standard regular expressions.
Definition: regex.h:860
_Out_iter regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last, const basic_regex< _Ch_type, _Rx_traits > &__e, const basic_string< _Ch_type, _St, _Sa > &__fmt, regex_constants::match_flag_type __flags=regex_constants::match_default)
Search for a regular expression within a range for multiple times, and replace the matched parts thro...
Definition: regex.h:2508
sub_match< const wchar_t * > wcsub_match
Regex submatch over a C-style null-terminated wide string.
Definition: regex.h:1046
regex_token_iterator< string::const_iterator > sregex_token_iterator
Token iterator for standard strings.
Definition: regex.h:2997
bool operator>=(const sub_match< _Bi_iter > &__lhs, const __sub_match_string< _Bi_iter, _Ch_traits, _Ch_alloc > &__rhs)
Tests the ordering of a regular expression submatch and a string.
Definition: regex.h:1302
bool regex_match(_Bi_iter __s, _Bi_iter __e, match_results< _Bi_iter, _Alloc > &__m, const basic_regex< _Ch_type, _Rx_traits > &__re, regex_constants::match_flag_type __flags=regex_constants::match_default)
Determines if there is a match between the regular expression e and all of the character sequence [fi...
Definition: regex.h:2202
bool operator==(const match_results< _Bi_iter, _Alloc > &__m1, const match_results< _Bi_iter, _Alloc > &__m2)
Compares two match_results for equality.
Definition: regex.h:2132
bool operator!=(const match_results< _Bi_iter, _Alloc > &__m1, const match_results< _Bi_iter, _Alloc > &__m2)
Compares two match_results for inequality.
Definition: regex.h:2157
bool regex_search(_Bi_iter __s, _Bi_iter __e, match_results< _Bi_iter, _Alloc > &__m, const basic_regex< _Ch_type, _Rx_traits > &__re, regex_constants::match_flag_type __flags=regex_constants::match_default)
Definition: regex.h:2360
bool operator>(const sub_match< _Bi_iter > &__lhs, const __sub_match_string< _Bi_iter, _Ch_traits, _Ch_alloc > &__rhs)
Tests the ordering of a regular expression submatch and a string.
Definition: regex.h:1290
bool operator>(typename iterator_traits< _Bi_iter >::value_type const *__lhs, const sub_match< _Bi_iter > &__rhs)
Tests the ordering of a C string and a regular expression submatch.
Definition: regex.h:1364
bool operator>=(const sub_match< _BiIter > &__lhs, const sub_match< _BiIter > &__rhs)
Tests the ordering of two regular expression submatches.
Definition: regex.h:1126
bool operator>(const sub_match< _BiIter > &__lhs, const sub_match< _BiIter > &__rhs)
Tests the ordering of two regular expression submatches.
Definition: regex.h:1137
bool operator==(typename iterator_traits< _Bi_iter >::value_type const &__lhs, const sub_match< _Bi_iter > &__rhs)
Tests the equivalence of a character and a regular expression submatch.
Definition: regex.h:1495
bool operator>(const __sub_match_string< _Bi_iter, _Ch_traits, _Ch_alloc > &__lhs, const sub_match< _Bi_iter > &__rhs)
Tests the ordering of a string and a regular expression submatch.
Definition: regex.h:1197
bool operator!=(typename iterator_traits< _Bi_iter >::value_type const &__lhs, const sub_match< _Bi_iter > &__rhs)
Tests the inequivalence of a character and a regular expression submatch.
Definition: regex.h:1508
basic_regex< wchar_t > wregex
Standard wide-character regular expressions.
Definition: regex.h:864
bool operator==(typename iterator_traits< _Bi_iter >::value_type const *__lhs, const sub_match< _Bi_iter > &__rhs)
Tests the equivalence of a C string and a regular expression submatch.
Definition: regex.h:1327
bool operator==(const sub_match< _BiIter > &__lhs, const sub_match< _BiIter > &__rhs)
Tests the equivalence of two regular expression submatches.
Definition: regex.h:1064
bool operator!=(const sub_match< _BiIter > &__lhs, const sub_match< _BiIter > &__rhs)
Tests the inequivalence of two regular expression submatches.
Definition: regex.h:1093
bool operator!=(const sub_match< _Bi_iter > &__lhs, const __sub_match_string< _Bi_iter, _Ch_traits, _Ch_alloc > &__rhs)
Tests the inequivalence of a regular expression submatch and a string.
Definition: regex.h:1266
bool operator>=(typename iterator_traits< _Bi_iter >::value_type const *__lhs, const sub_match< _Bi_iter > &__rhs)
Tests the ordering of a C string and a regular expression submatch.
Definition: regex.h:1376
constexpr back_insert_iterator< _Container > back_inserter(_Container &__x)
ISO C++ entities toplevel namespace is std.
bitset< _Nb > operator^(const bitset< _Nb > &__x, const bitset< _Nb > &__y) noexcept
Global bitwise operations on bitsets.
Definition: bitset:1453
constexpr iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const bitset< _Nb > &__x)
Global I/O operators for bitsets.
Definition: bitset:1540
bitset< _Nb > operator|(const bitset< _Nb > &__x, const bitset< _Nb > &__y) noexcept
Global bitwise operations on bitsets.
Definition: bitset:1444
bitset< _Nb > operator&(const bitset< _Nb > &__x, const bitset< _Nb > &__y) noexcept
Global bitwise operations on bitsets.
Definition: bitset:1435
GNU extensions for public use.
__numeric_traits_integer< _Tp > __int_traits
Convenience alias for __numeric_traits<integer-type>.
constexpr _Iterator __base(_Iterator __it)
constexpr syntax_option_type collate
constexpr syntax_option_type ECMAScript
constexpr syntax_option_type egrep
syntax_option_type
This is a bitmask type indicating how to interpret the regex.
constexpr syntax_option_type multiline
constexpr match_flag_type match_default
constexpr syntax_option_type awk
constexpr syntax_option_type extended
constexpr syntax_option_type basic
match_flag_type
This is a bitmask type indicating regex matching rules.
constexpr syntax_option_type icase
constexpr syntax_option_type optimize
constexpr match_flag_type format_default
constexpr syntax_option_type nosubs
constexpr syntax_option_type grep
initializer_list
is_same
Definition: type_traits:1435
typename _Size< _Alloc, difference_type >::type size_type
The allocator's size type.
Basis for explicit traits specializations.
Definition: char_traits.h:322
Managing sequences of characters and character-like objects.
Definition: cow_string.h:113
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
Definition: cow_string.h:2203
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
Definition: cow_string.h:910
const _CharT * data() const noexcept
Return const pointer to contents.
Definition: cow_string.h:2215
iterator begin()
Definition: cow_string.h:800
iterator end()
Definition: cow_string.h:819
Traits class for iterators.
Container class for localization functionality.
Facet for localized string comparison.
Primary class template ctype facet.
locale_type getloc() const noexcept
Gets the locale currently imbued in the regular expression object.
Definition: regex.h:760
basic_regex & assign(const basic_string< _Ch_type, _Ch_traits, _Alloc > &__s, flag_type __flags=ECMAScript)
Assigns a new regular expression to a regex object from a string containing a regular expression patt...
Definition: regex.h:660
basic_regex & assign(basic_regex &&__rhs) noexcept
Move-assigns one regular expression to another.
Definition: regex.h:602
unsigned int mark_count() const noexcept
Gets the number of marked subexpressions within the regular expression.
Definition: regex.h:726
basic_regex & assign(initializer_list< _Ch_type > __l, flag_type __flags=ECMAScript)
Assigns a new regular expression to a regex object.
Definition: regex.h:714
locale_type imbue(locale_type __loc)
Imbues the regular expression object with the given locale.
Definition: regex.h:748
basic_regex(const basic_regex &__rhs)=default
Copy-constructs a basic regular expression.
flag_type flags() const noexcept
Gets the flags used to construct the regular expression or in the last call to assign().
Definition: regex.h:738
basic_regex & operator=(const basic_string< _Ch_type, _Ch_traits, _Alloc > &__s)
Replaces a regular expression with a new one constructed from a string.
Definition: regex.h:583
basic_regex(const _Ch_type *__p, flag_type __f=ECMAScript)
Constructs a basic regular expression from the sequence [__p, __p + char_traits<_Ch_type>::length(__p...
Definition: regex.h:453
void swap(basic_regex &__rhs) noexcept
Swaps the contents of two regular expression objects.
Definition: regex.h:770
basic_regex(const std::basic_string< _Ch_type, _Ch_traits, _Ch_alloc > &__s, flag_type __f=ECMAScript)
Constructs a basic regular expression from the string s interpreted according to the flags in f.
Definition: regex.h:500
basic_regex & operator=(const _Ch_type *__p)
Replaces a regular expression with a new one constructed from a C-style null-terminated string.
Definition: regex.h:560
basic_regex & operator=(const basic_regex &)=default
Assigns one regular expression to another.
basic_regex(_FwdIter __first, _FwdIter __last, flag_type __f=ECMAScript)
Constructs a basic regular expression from the range [first, last) interpreted according to the flags...
Definition: regex.h:519
basic_regex & assign(const basic_regex &__rhs) noexcept
Assigns one regular expression to another.
Definition: regex.h:593
basic_regex & assign(const _Ch_type *__p, flag_type __flags=ECMAScript)
Assigns a new regular expression to a regex object from a C-style null-terminated string containing a...
Definition: regex.h:619
basic_regex(const _Ch_type *__p, std::size_t __len, flag_type __f=ECMAScript)
Constructs a basic regular expression from the sequence [p, p + len) interpreted according to the fla...
Definition: regex.h:468
basic_regex & assign(_InputIterator __first, _InputIterator __last, flag_type __flags=ECMAScript)
Assigns a new regular expression to a regex object.
Definition: regex.h:682
basic_regex & operator=(basic_regex &&)=default
Move-assigns one regular expression to another.
basic_regex & assign(const _Ch_type *__p, size_t __len, flag_type __flags=ECMAScript)
Assigns a new regular expression to a regex object from a C-style string containing a regular express...
Definition: regex.h:641
basic_regex(basic_regex &&__rhs) noexcept=default
Move-constructs a basic regular expression.
basic_regex(initializer_list< _Ch_type > __l, flag_type __f=ECMAScript)
Constructs a basic regular expression from an initializer list.
Definition: regex.h:531
basic_regex() noexcept
Definition: regex.h:437
basic_regex & operator=(initializer_list< _Ch_type > __l)
Replaces a regular expression with a new one constructed from an initializer list.
Definition: regex.h:572
~basic_regex()
Destroys a basic regular expression.
Definition: regex.h:537
The results of a match or search operation.
Definition: regex.h:1708
allocator_type get_allocator() const noexcept
Gets a copy of the allocator.
Definition: regex.h:2035
void swap(match_results &__that) noexcept
Swaps the contents of two match_results.
Definition: regex.h:2049
difference_type position(size_type __sub=0) const
Gets the offset of the beginning of the indicated submatch.
Definition: regex.h:1869
size_type size() const noexcept
Gets the number of matches and submatches.
Definition: regex.h:1822
_Out_iter format(_Out_iter __out, const char_type *__fmt_first, const char_type *__fmt_last, match_flag_type __flags=regex_constants::format_default) const
difference_type length(size_type __sub=0) const
Gets the length of the indicated submatch.
Definition: regex.h:1854
const_reference prefix() const
Gets a sub_match representing the match prefix.
Definition: regex.h:1914
size_type max_size() const noexcept
Gets the number of matches and submatches.
Definition: regex.h:1826
const_reference operator[](size_type __sub) const
Gets a sub_match reference for the match or submatch.
Definition: regex.h:1897
match_results(match_results &&) noexcept=default
Move constructs a match_results.
basic_string< char_type, _St, _Sa > format(const basic_string< char_type, _St, _Sa > &__fmt, match_flag_type __flags=regex_constants::format_default) const
Definition: regex.h:2001
match_results(const _Alloc &__a) noexcept
Constructs a default match_results container.
Definition: regex.h:1766
match_results(const match_results &)=default
Copy constructs a match_results.
_Out_iter format(_Out_iter __out, const basic_string< char_type, _St, _Sa > &__fmt, match_flag_type __flags=regex_constants::format_default) const
Definition: regex.h:1989
const_iterator cbegin() const noexcept
Gets an iterator to the start of the sub_match collection.
Definition: regex.h:1946
string_type str(size_type __sub=0) const
Gets the match or submatch converted to a string type.
Definition: regex.h:1882
const_iterator end() const noexcept
Gets an iterator to one-past-the-end of the collection.
Definition: regex.h:1953
const_reference suffix() const
Gets a sub_match representing the match suffix.
Definition: regex.h:1929
bool ready() const noexcept
Indicates if the match_results is ready.
Definition: regex.h:1805
bool empty() const noexcept
Indicates if the match_results contains no results.
Definition: regex.h:1835
string_type format(const char_type *__fmt, match_flag_type __flags=regex_constants::format_default) const
Definition: regex.h:2013
match_results()
Constructs a default match_results container.
Definition: regex.h:1759
const_iterator cend() const noexcept
Gets an iterator to one-past-the-end of the collection.
Definition: regex.h:1960
const_iterator begin() const noexcept
Gets an iterator to the start of the sub_match collection.
Definition: regex.h:1939
Takes a regex and an input string and does the matching.
Describes aspects of a regular expression.
Definition: regex.h:91
char_type translate(char_type __c) const
Performs the identity translation.
Definition: regex.h:194
string_type lookup_collatename(_Fwd_iter __first, _Fwd_iter __last) const
Gets a collation element by name.
char_class_type lookup_classname(_Fwd_iter __first, _Fwd_iter __last, bool __icase=false) const
Maps one or more characters to a named character classification.
static std::size_t length(const char_type *__p)
Gives the length of a C-style string starting at __p.
Definition: regex.h:183
string_type transform_primary(_Fwd_iter __first, _Fwd_iter __last) const
Gets a sort key for a character sequence, independent of case.
Definition: regex.h:260
regex_traits()
Constructs a default traits object.
Definition: regex.h:170
int value(_Ch_type __ch, int __radix) const
Converts a digit to an int.
char_type translate_nocase(char_type __c) const
Translates a character into a case-insensitive equivalent.
Definition: regex.h:207
locale_type getloc() const
Gets a copy of the current locale in use by the regex_traits object.
Definition: regex.h:383
bool isctype(_Ch_type __c, char_class_type __f) const
Determines if c is a member of an identified class.
locale_type imbue(locale_type __loc)
Imbues the regex_traits object with a copy of a new locale.
Definition: regex.h:372
string_type transform(_Fwd_iter __first, _Fwd_iter __last) const
Gets a sort key for a character sequence.
Definition: regex.h:236
difference_type length() const noexcept
Gets the length of the matching sequence.
Definition: regex.h:912
int compare(const value_type *__s) const
Compares this sub_match to a string.
Definition: regex.h:969
string_type str() const
Gets the matching sequence as a string.
Definition: regex.h:934
int compare(const sub_match &__s) const
Compares this and another matched sequence.
Definition: regex.h:951
int compare(const string_type &__s) const
Compares this sub_match to a string.
Definition: regex.h:965
regex_iterator & operator++()
Increments a regex_iterator.
bool operator!=(const regex_iterator &__rhs) const noexcept
Tests the inequivalence of two regex iterators.
Definition: regex.h:2713
regex_iterator operator++(int)
Postincrements a regex_iterator.
Definition: regex.h:2740
regex_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type &__re, regex_constants::match_flag_type __m=regex_constants::match_default)
Definition: regex.h:2679
regex_iterator(const regex_iterator &)=default
Copy constructs a regex_iterator.
regex_iterator()=default
Provides a singular iterator, useful for indicating one-past-the-end of a range.
regex_iterator & operator=(const regex_iterator &)=default
Copy assigns one regex_iterator to another.
const value_type & operator*() const noexcept
Dereferences a regex_iterator.
Definition: regex.h:2720
const value_type * operator->() const noexcept
Selects a regex_iterator member.
Definition: regex.h:2727
bool operator==(const regex_iterator &) const noexcept
Tests the equivalence of two regex iterators.
regex_token_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type &__re, const int(&__submatches)[_Nm], regex_constants::match_flag_type __m=regex_constants::match_default)
Definition: regex.h:2864
bool operator==(const regex_token_iterator &__rhs) const
Compares a regex_token_iterator to another for equality.
const value_type & operator*() const
Dereferences a regex_token_iterator.
Definition: regex.h:2925
regex_token_iterator(const regex_token_iterator &__rhs)
Copy constructs a regex_token_iterator.
Definition: regex.h:2896
regex_token_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type &__re, const std::vector< int > &__submatches, regex_constants::match_flag_type __m=regex_constants::match_default)
Definition: regex.h:2829
regex_token_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type &__re, initializer_list< int > __submatches, regex_constants::match_flag_type __m=regex_constants::match_default)
Definition: regex.h:2846
regex_token_iterator & operator++()
Increments a regex_token_iterator.
bool operator!=(const regex_token_iterator &__rhs) const
Compares a regex_token_iterator to another for inequality.
Definition: regex.h:2918
regex_token_iterator operator++(int)
Postincrements a regex_token_iterator.
Definition: regex.h:2945
regex_token_iterator()
Default constructs a regex_token_iterator.
Definition: regex.h:2791
regex_token_iterator & operator=(const regex_token_iterator &__rhs)
Assigns a regex_token_iterator to another.
const value_type * operator->() const
Selects a regex_token_iterator member.
Definition: regex.h:2932
regex_token_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type &__re, int __submatch=0, regex_constants::match_flag_type __m=regex_constants::match_default)
Definition: regex.h:2813
A smart pointer with reference-counted copy semantics.
Struct holding two objects of arbitrary type.
Definition: stl_pair.h:201
_BiIter first
The first member.
Definition: stl_pair.h:205
_BiIter second
The second member.
Definition: stl_pair.h:206
Forward iterators support a superset of input iterator operations.
A standard container which offers fixed time access to individual elements in any order.
Definition: stl_vector.h:422
constexpr iterator end() noexcept
Definition: stl_vector.h:881
constexpr iterator begin() noexcept
Definition: stl_vector.h:861
constexpr void assign(size_type __n, const value_type &__val)
Assigns a given value to a vector.
Definition: stl_vector.h:796
constexpr void swap(vector &__x) noexcept
Swaps data with another vector.
Definition: stl_vector.h:1574
constexpr bool empty() const noexcept
Definition: stl_vector.h:1076
constexpr allocator_type get_allocator() const noexcept
Get a copy of the memory allocation object.
Definition: stl_vector.h:306
constexpr size_type size() const noexcept
Definition: stl_vector.h:980
constexpr reference operator[](size_type __n) noexcept
Subscript access to the data contained in the vector.
Definition: stl_vector.h:1114
constexpr size_type max_size() const noexcept
Definition: stl_vector.h:986