31#if __cplusplus >= 202002L
38namespace std _GLIBCXX_VISIBILITY(default)
40_GLIBCXX_BEGIN_NAMESPACE_VERSION
41_GLIBCXX_BEGIN_NAMESPACE_CXX11
42 template<
typename,
typename>
45 template<
typename _Bi_iter,
typename _Alloc>
48_GLIBCXX_END_NAMESPACE_CXX11
52 enum class _RegexExecutorPolicy :
int { _S_auto, _S_alternate };
54 template<
typename _BiIter,
typename _Alloc,
55 typename _CharT,
typename _TraitsT>
57 __regex_algo_impl(_BiIter __s, _BiIter __e,
58 match_results<_BiIter, _Alloc>& __m,
59 const basic_regex<_CharT, _TraitsT>& __re,
61 _RegexExecutorPolicy __policy,
64_GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(_V2)
65 template<
typename,
typename,
typename>
67_GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2)
69 template<
typename _Tp>
72 template<
typename _Tp>
73 struct __is_contiguous_iter<_Tp*> :
true_type { };
75 template<
typename _Tp,
typename _Cont>
76 struct __is_contiguous_iter<__gnu_cxx::__normal_iterator<_Tp*, _Cont>>
80_GLIBCXX_BEGIN_NAMESPACE_CXX11
100 template<
typename _Ch_type>
104 typedef _Ch_type char_type;
111 typedef std::ctype_base::mask _BaseType;
113 unsigned char _M_extended;
114 static constexpr unsigned char _S_under = 1 << 0;
115 static constexpr unsigned char _S_valid_mask = 0x1;
117 constexpr _RegexMask(_BaseType __base = 0,
118 unsigned char __extended = 0)
119 : _M_base(__base), _M_extended(__extended)
125 return _RegexMask(_M_base & __other._M_base,
126 _M_extended & __other._M_extended);
132 return _RegexMask(_M_base | __other._M_base,
133 _M_extended | __other._M_extended);
139 return _RegexMask(_M_base ^ __other._M_base,
140 _M_extended ^ __other._M_extended);
145 {
return _RegexMask(~_M_base, ~_M_extended); }
148 operator&=(_RegexMask __other)
149 {
return *
this = (*this) & __other; }
152 operator|=(_RegexMask __other)
153 {
return *
this = (*this) | __other; }
156 operator^=(_RegexMask __other)
157 {
return *
this = (*this) ^ __other; }
160 operator==(_RegexMask __other)
const
162 return (_M_extended & _S_valid_mask)
163 == (__other._M_extended & _S_valid_mask)
164 && _M_base == __other._M_base;
167#if __cpp_impl_three_way_comparison < 201907L
169 operator!=(_RegexMask __other)
const
170 {
return !((*this) == __other); }
175 typedef _RegexMask char_class_type;
222 return __fctyp.tolower(__c);
245 template<
typename _Fwd_iter>
249 typedef std::collate<char_type> __collate_type;
251 string_type __s(__first, __last);
252 return __fclt.transform(__s.
data(), __s.
data() + __s.
size());
269 template<
typename _Fwd_iter>
276 if (
typeid(__fclt) !=
typeid(collate<char_type>))
285 const auto __p =
const_cast<char_type*
>(__s.
c_str());
286 const auto __pend = __p + __s.
size();
292 __fctyp.tolower(__p, __pend);
296 __ret = __fclt.transform(__p, __pend);
316 template<
typename _Fwd_iter>
357 template<
typename _Fwd_iter>
360 bool __icase =
false)
const;
375 isctype(_Ch_type __c, char_class_type __f)
const;
388 value(_Ch_type __ch,
int __radix)
const;
404 std::swap(_M_locale, __loc);
414 {
return _M_locale; }
417 locale_type _M_locale;
441 template<
typename _Ch_type,
typename _Rx_traits = regex_traits<_Ch_type>>
446 "regex traits class must have the same char_type");
449 typedef _Ch_type value_type;
450 typedef _Rx_traits traits_type;
451 typedef typename traits_type::string_type string_type;
453 typedef typename traits_type::locale_type locale_type;
470#if __cplusplus >= 201703L || !defined __STRICT_ANSI__
481 : _M_flags(ECMAScript), _M_loc(), _M_automaton(
nullptr)
497 { _M_compile(__p, __p + _Rx_traits::length(__p), __f); }
512 flag_type __f = ECMAScript)
514 __glibcxx_requires_string_len(__p, __len);
515 _M_compile(__p, __p + __len, __f);
541 template<
typename _Ch_traits,
typename _Ch_alloc>
545 flag_type __f = ECMAScript)
546 { _M_compile(__s.data(), __s.data() + __s.size(), __f); }
561 template<
typename _FwdIter>
563 flag_type __f = ECMAScript)
564 { this->
assign(__first, __last, __f); }
575 { _M_compile(__l.begin(), __l.end(), __f); }
604 {
return this->
assign(__p); }
616 {
return this->
assign(__l); }
624 template<
typename _Ch_traits,
typename _Alloc>
627 {
return this->
assign(__s); }
637 {
return *
this = __rhs; }
662 assign(
const _Ch_type* __p, flag_type __flags = ECMAScript)
664 _M_compile(__p, __p + _Rx_traits::length(__p), __flags);
684 assign(
const _Ch_type* __p,
size_t __len, flag_type __flags = ECMAScript)
686 _M_compile(__p, __p + __len, __flags);
701 template<
typename _Ch_traits,
typename _Alloc>
704 flag_type __flags = ECMAScript)
706 _M_compile(__s.
data(), __s.
data() + __s.
size(), __flags);
723 template<
typename _InputIterator>
725 assign(_InputIterator __first, _InputIterator __last,
726 flag_type __flags = ECMAScript)
728#if __cpp_if_constexpr >= 201606L
730 if constexpr (__detail::__is_contiguous_iter<_InputIterator>::value
731 && is_same_v<_ValT, value_type>)
733 __glibcxx_requires_valid_range(__first, __last);
734 if constexpr (is_pointer_v<_InputIterator>)
735 _M_compile(__first, __last, __flags);
737 _M_compile(__first.base(), __last.base(), __flags);
741 this->
assign(string_type(__first, __last), __flags);
759 _M_compile(__l.begin(), __l.end(), __flags);
772 return _M_automaton->_M_sub_count() - 1;
793 std::swap(__loc, _M_loc);
794 _M_automaton.reset();
815 std::swap(_M_flags, __rhs._M_flags);
816 std::swap(_M_loc, __rhs._M_loc);
817 std::swap(_M_automaton, __rhs._M_automaton);
823 { _M_automaton->_M_dot(__ostr); }
830 _M_compile(
const _Ch_type* __first,
const _Ch_type* __last,
833 __detail::_Compiler<_Rx_traits> __c(__first, __last, _M_loc, __f);
834 _M_automaton = __c._M_get_nfa();
838 template<
typename _Bp,
typename _Ap,
typename _Cp,
typename _Rp>
840 __detail::__regex_algo_impl(_Bp, _Bp, match_results<_Bp, _Ap>&,
843 __detail::_RegexExecutorPolicy,
bool);
845 template<
typename,
typename,
typename>
846 friend class __detail::_Executor;
850 _AutomatonPtr _M_automaton;
853#if ! __cpp_inline_variables
854 template<
typename _Ch,
typename _Tr>
856 basic_regex<_Ch, _Tr>::icase;
858 template<
typename _Ch,
typename _Tr>
860 basic_regex<_Ch, _Tr>::nosubs;
862 template<
typename _Ch,
typename _Tr>
864 basic_regex<_Ch, _Tr>::optimize;
866 template<
typename _Ch,
typename _Tr>
868 basic_regex<_Ch, _Tr>::collate;
870 template<
typename _Ch,
typename _Tr>
872 basic_regex<_Ch, _Tr>::ECMAScript;
874 template<
typename _Ch,
typename _Tr>
876 basic_regex<_Ch, _Tr>::basic;
878 template<
typename _Ch,
typename _Tr>
880 basic_regex<_Ch, _Tr>::extended;
882 template<
typename _Ch,
typename _Tr>
884 basic_regex<_Ch, _Tr>::awk;
886 template<
typename _Ch,
typename _Tr>
888 basic_regex<_Ch, _Tr>::grep;
890 template<
typename _Ch,
typename _Tr>
892 basic_regex<_Ch, _Tr>::egrep;
895#if __cpp_deduction_guides >= 201606
896 template<
typename _ForwardIterator>
905#ifdef _GLIBCXX_USE_WCHAR_T
918 template<
typename _Ch_type,
typename _Rx_traits>
922 { __lhs.swap(__rhs); }
943 template<
typename _BiIter>
952 typedef typename __iter_traits::value_type value_type;
953 typedef typename __iter_traits::difference_type difference_type;
954 typedef _BiIter iterator;
957 _GLIBCXX_DOXYGEN_ONLY(iterator first; iterator second;)
961 constexpr sub_match() noexcept : matched() { }
966 {
return this->matched ?
std::distance(this->first, this->second) : 0; }
978 operator string_type()
const
990 ? string_type(this->first, this->second)
1005 {
return this->_M_str().compare(__s._M_str()); }
1019 {
return this->_M_str().compare(__s); }
1023 {
return this->_M_str().compare(__s); }
1029 _M_compare(
const value_type* __s,
size_t __n)
const
1030 {
return this->_M_str().compare({__s, __n}); }
1037 swap(sub_match& __s)
noexcept(__is_nothrow_swappable<_BiIter>::value)
1040 std::swap(matched, __s.matched);
1045 struct __string_view
1047 using traits_type =
typename string_type::traits_type;
1049 __string_view() =
default;
1051 __string_view(
const value_type* __s,
size_t __n) noexcept
1052 : _M_data(__s), _M_len(__n) { }
1054 __string_view(
const value_type* __s) noexcept
1055 : _M_data(__s), _M_len(traits_type::length(__s)) { }
1057 __string_view(
const string_type& __s) noexcept
1058 : _M_data(__s.data()), _M_len(__s.length()) { }
1061 compare(__string_view __s)
const noexcept
1063 if (
const size_t __n =
std::min(_M_len, __s._M_len))
1064 if (
int __ret = traits_type::compare(_M_data, __s._M_data, __n))
1067 const difference_type __diff = _M_len - __s._M_len;
1068 if (__diff > __limits::__max)
1069 return __limits::__max;
1070 if (__diff < __limits::__min)
1071 return __limits::__min;
1072 return static_cast<int>(__diff);
1076 const value_type* _M_data =
nullptr;
1081 template<
typename _Iter = _BiIter>
1082 __enable_if_t<__detail::__is_contiguous_iter<_Iter>::value,
1084 _M_str() const noexcept
1087 if (
size_t __len = this->second - this->first)
1093 template<
typename _Iter = _BiIter>
1094 __enable_if_t<!__detail::__is_contiguous_iter<_Iter>::value,
1107#ifdef _GLIBCXX_USE_WCHAR_T
1125 template<
typename _BiIter>
1127 operator==(
const sub_match<_BiIter>& __lhs,
const sub_match<_BiIter>& __rhs)
1128 {
return __lhs.
compare(__rhs) == 0; }
1130#if __cpp_lib_three_way_comparison
1138 template<
typename _BiIter>
1141 const sub_match<_BiIter>& __rhs)
1142 noexcept(__detail::__is_contiguous_iter<_BiIter>::value)
1145 return __detail::__char_traits_cmp_cat<_Tr>(__lhs.compare(__rhs));
1154 template<
typename _BiIter>
1157 {
return __lhs.
compare(__rhs) != 0; }
1165 template<
typename _BiIter>
1167 operator<(
const sub_match<_BiIter>& __lhs,
const sub_match<_BiIter>& __rhs)
1168 {
return __lhs.compare(__rhs) < 0; }
1176 template<
typename _BiIter>
1179 {
return __lhs.compare(__rhs) <= 0; }
1187 template<
typename _BiIter>
1190 {
return __lhs.compare(__rhs) >= 0; }
1198 template<
typename _BiIter>
1201 {
return __lhs.compare(__rhs) > 0; }
1207 template<
typename _Bi_iter,
typename _Ch_traits,
typename _Ch_alloc>
1210 _Ch_traits, _Ch_alloc>;
1213#if ! __cpp_lib_three_way_comparison
1221 template<
typename _Bi_iter,
typename _Ch_traits,
typename _Ch_alloc>
1223 operator==(
const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
1225 {
return __rhs._M_compare(__lhs.data(), __lhs.size()) == 0; }
1234 template<
typename _Bi_iter,
typename _Ch_traits,
typename _Ch_alloc>
1236 operator!=(
const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
1238 {
return !(__lhs == __rhs); }
1246 template<
typename _Bi_iter,
typename _Ch_traits,
typename _Ch_alloc>
1248 operator<(
const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
1250 {
return __rhs._M_compare(__lhs.data(), __lhs.size()) > 0; }
1258 template<
typename _Bi_iter,
typename _Ch_traits,
typename _Ch_alloc>
1260 operator>(
const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
1262 {
return __rhs < __lhs; }
1270 template<
typename _Bi_iter,
typename _Ch_traits,
typename _Ch_alloc>
1272 operator>=(
const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
1274 {
return !(__lhs < __rhs); }
1282 template<
typename _Bi_iter,
typename _Ch_traits,
typename _Ch_alloc>
1284 operator<=(
const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
1286 {
return !(__rhs < __lhs); }
1296 template<
typename _Bi_iter,
typename _Ch_traits,
typename _Ch_alloc>
1299 const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
1300 {
return __lhs._M_compare(__rhs.data(), __rhs.size()) == 0; }
1302#if __cpp_lib_three_way_comparison
1310 template<
typename _Bi_iter,
typename _Ch_traits,
typename _Alloc>
1313 const __sub_match_string<_Bi_iter, _Ch_traits, _Alloc>& __rhs)
1314 noexcept(__detail::__is_contiguous_iter<_Bi_iter>::value)
1316 return __detail::__char_traits_cmp_cat<_Ch_traits>(
1317 __lhs._M_compare(__rhs.data(), __rhs.size()));
1327 template<
typename _Bi_iter,
typename _Ch_traits,
typename _Ch_alloc>
1330 const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
1331 {
return !(__lhs == __rhs); }
1339 template<
typename _Bi_iter,
typename _Ch_traits,
typename _Ch_alloc>
1341 operator<(
const sub_match<_Bi_iter>& __lhs,
1342 const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
1343 {
return __lhs._M_compare(__rhs.data(), __rhs.size()) < 0; }
1351 template<
typename _Bi_iter,
typename _Ch_traits,
typename _Ch_alloc>
1354 const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
1355 {
return __rhs < __lhs; }
1363 template<
typename _Bi_iter,
typename _Ch_traits,
typename _Ch_alloc>
1366 const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
1367 {
return !(__lhs < __rhs); }
1375 template<
typename _Bi_iter,
typename _Ch_traits,
typename _Ch_alloc>
1378 const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
1379 {
return !(__rhs < __lhs); }
1388 template<
typename _Bi_iter>
1392 {
return __rhs.compare(__lhs) == 0; }
1401 template<
typename _Bi_iter>
1405 {
return !(__lhs == __rhs); }
1413 template<
typename _Bi_iter>
1417 {
return __rhs.compare(__lhs) > 0; }
1425 template<
typename _Bi_iter>
1429 {
return __rhs < __lhs; }
1437 template<
typename _Bi_iter>
1441 {
return !(__lhs < __rhs); }
1449 template<
typename _Bi_iter>
1453 {
return !(__rhs < __lhs); }
1463 template<
typename _Bi_iter>
1467 {
return __lhs.
compare(__rhs) == 0; }
1469#if __cpp_lib_three_way_comparison
1478 template<
typename _Bi_iter>
1482 noexcept(__detail::__is_contiguous_iter<_Bi_iter>::value)
1485 return __detail::__char_traits_cmp_cat<_Tr>(__lhs.compare(__rhs));
1495 template<
typename _Bi_iter>
1499 {
return !(__lhs == __rhs); }
1507 template<
typename _Bi_iter>
1509 operator<(
const sub_match<_Bi_iter>& __lhs,
1510 typename iterator_traits<_Bi_iter>::value_type
const* __rhs)
1511 {
return __lhs.compare(__rhs) < 0; }
1519 template<
typename _Bi_iter>
1523 {
return __rhs < __lhs; }
1531 template<
typename _Bi_iter>
1535 {
return !(__lhs < __rhs); }
1543 template<
typename _Bi_iter>
1547 {
return !(__rhs < __lhs); }
1556 template<
typename _Bi_iter>
1569 template<
typename _Bi_iter>
1573 {
return !(__lhs == __rhs); }
1582 template<
typename _Bi_iter>
1595 template<
typename _Bi_iter>
1599 {
return __rhs < __lhs; }
1608 template<
typename _Bi_iter>
1612 {
return !(__lhs < __rhs); }
1621 template<
typename _Bi_iter>
1625 {
return !(__rhs < __lhs); }
1635 template<
typename _Bi_iter>
1641#if __cpp_lib_three_way_comparison
1651 template<
typename _Bi_iter>
1655 noexcept(__detail::__is_contiguous_iter<_Bi_iter>::value)
1658 return __detail::__char_traits_cmp_cat<_Tr>(
1669 template<
typename _Bi_iter>
1673 {
return !(__lhs == __rhs); }
1682 template<
typename _Bi_iter>
1684 operator<(
const sub_match<_Bi_iter>& __lhs,
1685 typename iterator_traits<_Bi_iter>::value_type
const& __rhs)
1695 template<
typename _Bi_iter>
1699 {
return __rhs < __lhs; }
1708 template<
typename _Bi_iter>
1712 {
return !(__lhs < __rhs); }
1721 template<
typename _Bi_iter>
1725 {
return !(__rhs < __lhs); }
1736 template<
typename _Ch_type,
typename _Ch_traits,
typename _Bi_iter>
1741 {
return __os << __m.str(); }
1770 template<
typename _Bi_iter,
1773 :
private std::vector<sub_match<_Bi_iter>, _Alloc>
1794 typedef _GLIBCXX_STD_C::vector<sub_match<_Bi_iter>, _Alloc> _Unchecked;
1804 typedef const value_type& const_reference;
1805 typedef value_type& reference;
1806 typedef typename _Base_type::const_iterator const_iterator;
1807 typedef const_iterator iterator;
1808 typedef typename __iter_traits::difference_type difference_type;
1810 typedef _Alloc allocator_type;
1811 typedef typename __iter_traits::value_type char_type;
1867 : _Base_type(__m, __a) { }
1870 noexcept(
noexcept(_Base_type(
std::move(__m), __a)))
1871 : _Base_type(
std::
move(__m), __a) { }
1910 _GLIBCXX_NODISCARD
bool
1931 {
return (*
this)[__sub].length(); }
1958 str(size_type __sub = 0)
const
1959 {
return string_type((*
this)[__sub]); }
1975 __glibcxx_assert(
ready() );
1976 return __sub <
size()
1978 : _M_unmatched_sub();
1992 __glibcxx_assert(
ready() );
1993 return !
empty() ? _M_prefix() : _M_unmatched_sub();
2007 __glibcxx_assert(
ready() );
2008 return !
empty() ? _M_suffix() : _M_unmatched_sub();
2023 {
return this->
begin(); }
2037 {
return this->
end(); }
2054 template<
typename _Out_iter>
2056 format(_Out_iter __out,
const char_type* __fmt_first,
2057 const char_type* __fmt_last,
2063 template<
typename _Out_iter,
typename _St,
typename _Sa>
2075 template<
typename _St,
typename _Sa>
2092 string_type __result;
2095 __fmt + char_traits<char_type>::length(__fmt),
2129 swap(_M_begin, __that._M_begin);
2134 template<
typename,
typename,
typename>
2139 template<
typename,
typename,
typename>
2140 friend class __detail::_Executor;
2142 template<
typename _Bp,
typename _Ap,
typename _Cp,
typename _Rp>
2147 __detail::_RegexExecutorPolicy,
bool);
2152 _M_resize(
unsigned int __size)
2157 _M_establish_failed_match(_Bi_iter __end)
2159 sub_match<_Bi_iter> __sm;
2160 __sm.first = __sm.second = __end;
2165 _M_unmatched_sub()
const
2168 sub_match<_Bi_iter>&
2176 sub_match<_Bi_iter>&
2184 sub_match<_Bi_iter>&
2188 _Bi_iter _M_begin {};
2194#ifdef _GLIBCXX_USE_WCHAR_T
2208 template<
typename _Bi_iter,
typename _Alloc>
2227#if ! __cpp_lib_three_way_comparison
2235 template<
typename _Bi_iter,
class _Alloc>
2239 {
return !(__m1 == __m2); }
2252 template<
typename _Bi_iter,
typename _Alloc>
2256 { __lhs.swap(__rhs); }
2258_GLIBCXX_END_NAMESPACE_CXX11
2282 template<
typename _Bi_iter,
typename _Alloc,
2283 typename _Ch_type,
typename _Rx_traits>
2292 return __detail::__regex_algo_impl(__s, __e, __m, __re, __flags,
2293 __detail::_RegexExecutorPolicy::_S_auto,
true);
2310 template<
typename _Bi_iter,
typename _Ch_type,
typename _Rx_traits>
2318 return regex_match(__first, __last, __what, __re, __flags);
2335 template<
typename _Ch_type,
typename _Alloc,
typename _Rx_traits>
2342 {
return regex_match(__s, __s + _Rx_traits::length(__s), __m, __re, __f); }
2358 template<
typename _Ch_traits,
typename _Ch_alloc,
2359 typename _Alloc,
typename _Ch_type,
typename _Rx_traits>
2363 _Ch_traits, _Ch_alloc>::const_iterator, _Alloc>& __m,
2372 template<
typename _Ch_traits,
typename _Ch_alloc,
2373 typename _Alloc,
typename _Ch_type,
typename _Rx_traits>
2377 _Ch_traits, _Ch_alloc>::const_iterator, _Alloc>&,
2395 template<
typename _Ch_type,
class _Rx_traits>
2401 {
return regex_match(__s, __s + _Rx_traits::length(__s), __re, __f); }
2416 template<
typename _Ch_traits,
typename _Str_allocator,
2417 typename _Ch_type,
typename _Rx_traits>
2439 template<
typename _Bi_iter,
typename _Alloc,
2440 typename _Ch_type,
typename _Rx_traits>
2448 return __detail::__regex_algo_impl(__s, __e, __m, __re, __flags,
2449 __detail::_RegexExecutorPolicy::_S_auto,
false);
2463 template<
typename _Bi_iter,
typename _Ch_type,
typename _Rx_traits>
2471 return regex_search(__first, __last, __what, __re, __flags);
2486 template<
typename _Ch_type,
class _Alloc,
class _Rx_traits>
2493 {
return regex_search(__s, __s + _Rx_traits::length(__s), __m, __e, __f); }
2505 template<
typename _Ch_type,
typename _Rx_traits>
2511 {
return regex_search(__s, __s + _Rx_traits::length(__s), __e, __f); }
2523 template<
typename _Ch_traits,
typename _String_allocator,
2524 typename _Ch_type,
typename _Rx_traits>
2527 _String_allocator>& __s,
2531 {
return regex_search(__s.begin(), __s.end(), __e, __flags); }
2545 template<
typename _Ch_traits,
typename _Ch_alloc,
2546 typename _Alloc,
typename _Ch_type,
2547 typename _Rx_traits>
2551 _Ch_traits, _Ch_alloc>::const_iterator, _Alloc>& __m,
2560 template<
typename _Ch_traits,
typename _Ch_alloc,
2561 typename _Alloc,
typename _Ch_type,
2562 typename _Rx_traits>
2566 _Ch_traits, _Ch_alloc>::const_iterator, _Alloc>&,
2574 template<
typename _Out_iter,
typename _Bi_iter,
2575 typename _Rx_traits,
typename _Ch_type>
2577 __regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
2579 const _Ch_type* __fmt,
size_t __len,
2596 template<
typename _Out_iter,
typename _Bi_iter,
2597 typename _Rx_traits,
typename _Ch_type,
2598 typename _St,
typename _Sa>
2606 return std::__regex_replace(__out, __first, __last, __e, __fmt.
c_str(),
2607 __fmt.
length(), __flags);
2623 template<
typename _Out_iter,
typename _Bi_iter,
2624 typename _Rx_traits,
typename _Ch_type>
2628 const _Ch_type* __fmt,
2632 return std::__regex_replace(__out, __first, __last, __e, __fmt,
2633 char_traits<_Ch_type>::length(__fmt),
2649 template<
typename _Rx_traits,
typename _Ch_type,
2650 typename _St,
typename _Sa,
typename _Fst,
typename _Fsa>
2651 inline basic_string<_Ch_type, _St, _Sa>
2660 __s.
begin(), __s.
end(), __e, __fmt, __flags);
2675 template<
typename _Rx_traits,
typename _Ch_type,
2676 typename _St,
typename _Sa>
2677 inline basic_string<_Ch_type, _St, _Sa>
2680 const _Ch_type* __fmt,
2686 __s.
begin(), __s.
end(), __e, __fmt, __flags);
2701 template<
typename _Rx_traits,
typename _Ch_type,
2702 typename _St,
typename _Sa>
2703 inline basic_string<_Ch_type>
2712 __s + char_traits<_Ch_type>::length(__s),
2713 __e, __fmt, __flags);
2728 template<
typename _Rx_traits,
typename _Ch_type>
2729 inline basic_string<_Ch_type>
2732 const _Ch_type* __fmt,
2738 __s + char_traits<_Ch_type>::length(__s),
2739 __e, __fmt, __flags);
2745_GLIBCXX_BEGIN_NAMESPACE_CXX11
2755 template<
typename _Bi_iter,
2756 typename _Ch_type =
typename iterator_traits<_Bi_iter>::value_type,
2757 typename _Rx_traits = regex_traits<_Ch_type> >
2763 typedef std::ptrdiff_t difference_type;
2764 typedef const value_type* pointer;
2765 typedef const value_type& reference;
2767#if __cplusplus > 201703L
2787 : _M_begin(__a), _M_end(__b), _M_pregex(&__re), _M_flags(__m), _M_match()
2789 if (!
regex_search(_M_begin, _M_end, _M_match, *_M_pregex, _M_flags))
2814#if __cplusplus >= 202002L
2818 {
return _M_pregex ==
nullptr; }
2821#if __cpp_impl_three_way_comparison < 201907L
2827 {
return !(*
this == __rhs); }
2835 {
return _M_match; }
2842 {
return &_M_match; }
2862 _Bi_iter _M_begin {};
2864 const regex_type* _M_pregex =
nullptr;
2866 match_results<_Bi_iter> _M_match;
2871#ifdef _GLIBCXX_USE_WCHAR_T
2887 template<
typename _Bi_iter,
2895 typedef std::ptrdiff_t difference_type;
2896 typedef const value_type* pointer;
2897 typedef const value_type& reference;
2899#if __cplusplus > 201703L
2912 : _M_position(), _M_subs(), _M_suffix(), _M_n(0), _M_result(nullptr),
2937 : _M_position(__a, __b, __re, __m), _M_subs(1, __submatch), _M_n(0)
2938 { _M_init(__a, __b); }
2950 const regex_type& __re,
2954 : _M_position(__a, __b, __re, __m), _M_subs(__submatches), _M_n(0)
2955 { _M_init(__a, __b); }
2967 const regex_type& __re,
2971 : _M_position(__a, __b, __re, __m), _M_subs(__submatches), _M_n(0)
2972 { _M_init(__a, __b); }
2983 template<std::
size_t _Nm>
2985 const regex_type& __re,
2986 const int (&__submatches)[_Nm],
2989 : _M_position(__a, __b, __re, __m),
2990 _M_subs(__submatches, __submatches + _Nm), _M_n(0)
2991 { _M_init(__a, __b); }
3006 template <std::
size_t _Nm>
3017 : _M_position(__rhs._M_position), _M_subs(__rhs._M_subs),
3018 _M_suffix(__rhs._M_suffix), _M_n(__rhs._M_n), _M_has_m1(__rhs._M_has_m1)
3019 { _M_normalize_result(); }
3034#if __cplusplus >= 202002L
3038 {
return _M_end_of_seq(); }
3041#if __cpp_impl_three_way_comparison < 201907L
3047 {
return !(*
this == __rhs); }
3055 {
return *_M_result; }
3062 {
return _M_result; }
3085 _M_init(_Bi_iter __a, _Bi_iter __b);
3088 _M_current_match()
const
3090 if (_M_subs[_M_n] == -1)
3091 return (*_M_position).prefix();
3093 return (*_M_position)[_M_subs[_M_n]];
3097 _M_end_of_seq() const noexcept
3098 {
return _M_result ==
nullptr; }
3102 _M_normalize_result()
3104 if (_M_position != _Position())
3105 _M_result = &_M_current_match();
3107 _M_result = &_M_suffix;
3109 _M_result =
nullptr;
3112 _Position _M_position;
3113 std::vector<int> _M_subs;
3114 value_type _M_suffix;
3116 const value_type* _M_result;
3128#ifdef _GLIBCXX_USE_WCHAR_T
3138_GLIBCXX_END_NAMESPACE_CXX11
3139_GLIBCXX_END_NAMESPACE_VERSION
basic_ostream< char > ostream
Base class for char output streams.
__bool_constant< true > true_type
The type used as a compile-time boolean with true value.
__bool_constant< false > false_type
The type used as a compile-time boolean with false value.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
constexpr const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
const _Facet & use_facet(const locale &__loc)
Return a facet.
sub_match< wstring::const_iterator > wssub_match
Regex submatch over a standard wide string.
auto operator<=>(const sub_match< const char * > &__lhs, const sub_match< const char * > &__rhs) noexcept(__detail::__is_contiguous_iter< const char * >::value)
sub_match< string::const_iterator > ssub_match
Standard regex submatch over a standard string.
sub_match< const char * > csub_match
Standard regex submatch over a C-style null-terminated string.
regex_token_iterator< const char * > cregex_token_iterator
Token iterator for C-style NULL-terminated strings.
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.
regex_token_iterator< wstring::const_iterator > wsregex_token_iterator
Token iterator for standard wide-character strings.
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.
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.
regex_token_iterator< const wchar_t * > wcregex_token_iterator
Token iterator for C-style NULL-terminated wide strings.
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.
basic_regex< char > regex
Standard regular expressions.
_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...
sub_match< const wchar_t * > wcsub_match
Regex submatch over a C-style null-terminated wide string.
regex_token_iterator< string::const_iterator > sregex_token_iterator
Token iterator for standard strings.
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...
bool operator==(const match_results< _BidirectionalIterator, polymorphic_allocator< sub_match< _BidirectionalIterator > > > &__m1, const match_results< _BidirectionalIterator, polymorphic_allocator< sub_match< _BidirectionalIterator > > > &__m2)
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)
void swap(match_results< _BidirectionalIterator, polymorphic_allocator< sub_match< _BidirectionalIterator > > > &__lhs, match_results< _BidirectionalIterator, polymorphic_allocator< sub_match< _BidirectionalIterator > > > &__rhs) noexcept
basic_regex< wchar_t > wregex
Standard wide-character regular expressions.
bool operator==(const sub_match< _BiIter > &__lhs, const sub_match< _BiIter > &__rhs)
Tests the equivalence of two regular expression submatches.
constexpr back_insert_iterator< _Container > back_inserter(_Container &__x)
ISO C++ entities toplevel namespace is std.
constexpr iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
constexpr bitset< _Nb > operator^(const bitset< _Nb > &__x, const bitset< _Nb > &__y) noexcept
Global bitwise operations on bitsets.
std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const bitset< _Nb > &__x)
Global I/O operators for bitsets.
constexpr bitset< _Nb > operator|(const bitset< _Nb > &__x, const bitset< _Nb > &__y) noexcept
Global bitwise operations on bitsets.
constexpr bitset< _Nb > operator&(const bitset< _Nb > &__x, const bitset< _Nb > &__y) noexcept
Global bitwise operations on bitsets.
Implementation details not part of the namespace std interface.
__numeric_traits_integer< _Tp > __int_traits
Convenience alias for __numeric_traits<integer-type>.
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
typename _Size< _Alloc, difference_type >::type size_type
The allocator's size type.
The standard allocator, as per C++03 [20.4.1].
Managing sequences of characters and character-like objects.
constexpr const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
constexpr size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
constexpr const _CharT * data() const noexcept
Return const pointer to contents.
constexpr size_type length() const noexcept
constexpr iterator end() noexcept
constexpr iterator begin() noexcept
Basis for explicit traits specializations.
Base class for all library exceptions.
Template class basic_ostream.
Traits class for iterators.
Container class for localization functionality.
Primary class template ctype facet.
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...
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...
locale_type getloc() const noexcept
Gets the locale currently imbued in the regular expression object.
unsigned int mark_count() const noexcept
Gets the number of marked subexpressions within the regular expression.
basic_regex & assign(_InputIterator __first, _InputIterator __last, flag_type __flags=ECMAScript)
Assigns a new regular expression to a regex object.
locale_type imbue(locale_type __loc)
Imbues the regular expression object with the given locale.
basic_regex(const basic_regex &__rhs)=default
Copy-constructs a basic regular expression.
basic_regex & assign(initializer_list< _Ch_type > __l, flag_type __flags=ECMAScript)
Assigns a new regular expression to a regex object.
basic_regex & assign(basic_regex &&__rhs) noexcept
Move-assigns one regular expression to another.
flag_type flags() const noexcept
Gets the flags used to construct the regular expression or in the last call to assign().
basic_regex & operator=(basic_regex &&)=default
Move-assigns one regular expression to another.
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...
void swap(basic_regex &__rhs) noexcept
Swaps the contents of two regular expression objects.
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.
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...
basic_regex & operator=(const basic_regex &)=default
Assigns one regular expression to another.
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...
basic_regex & operator=(initializer_list< _Ch_type > __l)
Replaces a regular expression with a new one constructed from an initializer list.
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...
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.
basic_regex & operator=(const _Ch_type *__p)
Replaces a regular expression with a new one constructed from a C-style null-terminated string.
basic_regex & assign(const basic_regex &__rhs) noexcept
Assigns one regular expression to another.
basic_regex & operator=(const basic_string< _Ch_type, _Ch_traits, _Alloc > &__s)
Replaces a regular expression with a new one constructed from a string.
~basic_regex()
Destroys a basic regular expression.
The results of a match or search operation.
allocator_type get_allocator() const noexcept
void swap(match_results &__that) noexcept
difference_type position(size_type __sub=0) const
size_type size() const noexcept
_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
const_reference prefix() const
match_results(match_results &&__m, const polymorphic_allocator< sub_match< _BidirectionalIterator > > &__a) noexcept(noexcept(_Base_type(std::move(__m), __a)))
size_type max_size() const noexcept
basic_string< char_type, _St, _Sa > format(const basic_string< char_type, _St, _Sa > &__fmt, match_flag_type __flags=regex_constants::format_default) const
const_reference operator[](size_type __sub) const
match_results(match_results &&) noexcept=default
match_results(const polymorphic_allocator< sub_match< _BidirectionalIterator > > &__a) noexcept
match_results(const match_results &)=default
_Out_iter format(_Out_iter __out, const basic_string< char_type, _St, _Sa > &__fmt, match_flag_type __flags=regex_constants::format_default) const
const_iterator cbegin() const noexcept
string_type str(size_type __sub=0) const
const_iterator end() const noexcept
const_reference suffix() const
bool ready() const noexcept
bool empty() const noexcept
string_type format(const char_type *__fmt, match_flag_type __flags=regex_constants::format_default) const
match_results()
Constructs a default match_results container.
const_iterator cend() const noexcept
const_iterator begin() const noexcept
Describes aspects of a regular expression.
char_type translate(char_type __c) const
Performs the identity translation.
static std::size_t length(const char_type *__p)
Gives the length of a C-style string starting at __p.
string_type transform_primary(_Fwd_iter __first, _Fwd_iter __last) const
Gets a sort key for a character sequence, independent of case.
regex_traits()
Constructs a default traits object.
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.
string_type lookup_collatename(_Fwd_iter __first, _Fwd_iter __last) const
Gets a collation element by name.
locale_type getloc() const
Gets a copy of the current locale in use by the regex_traits object.
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.
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.
string_type transform(_Fwd_iter __first, _Fwd_iter __last) const
Gets a sort key for a character sequence.
difference_type length() const noexcept
Gets the length of the matching sequence.
void swap(sub_match &__s) noexcept(__is_nothrow_swappable< _BiIter >::value)
Swap the values of two sub_match objects.
int compare(const value_type *__s) const
Compares this sub_match to a string.
string_type str() const
Gets the matching sequence as a string.
int compare(const sub_match &__s) const
Compares this and another matched sequence.
int compare(const string_type &__s) const
Compares this sub_match to a string.
const value_type * operator->() const noexcept
Selects a regex_iterator member.
regex_iterator operator++(int)
Postincrements a regex_iterator.
regex_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type &__re, regex_constants::match_flag_type __m=regex_constants::match_default)
regex_iterator(const regex_iterator &)=default
Copy constructs a regex_iterator.
regex_iterator & operator=(const regex_iterator &)=default
Copy assigns one regex_iterator to another.
regex_iterator()=default
Provides a singular iterator, useful for indicating one-past-the-end of a range.
const value_type & operator*() const noexcept
Dereferences a regex_iterator.
bool operator==(const regex_iterator &) const noexcept
Tests the equivalence of two regex iterators.
regex_iterator & operator++()
Increments a regex_iterator.
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)
bool operator==(const regex_token_iterator &__rhs) const
Compares a regex_token_iterator to another for equality.
regex_token_iterator(const regex_token_iterator &__rhs)
Copy constructs a regex_token_iterator.
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)
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)
regex_token_iterator operator++(int)
Postincrements a regex_token_iterator.
const value_type * operator->() const
Selects a regex_token_iterator member.
regex_token_iterator & operator=(const regex_token_iterator &__rhs)
Assigns a regex_token_iterator to another.
regex_token_iterator & operator++()
Increments a regex_token_iterator.
regex_token_iterator()
Default constructs a regex_token_iterator.
const value_type & operator*() const
Dereferences a regex_token_iterator.
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)
A smart pointer with reference-counted copy semantics.
Struct holding two objects (or references) of arbitrary type.
constexpr void swap(pair &__p) noexcept(__and_< __is_nothrow_swappable< _T1 >, __is_nothrow_swappable< _T2 > >::value)
Swap the first members and then the second members.
Forward iterators support a superset of input iterator operations.
A standard container which offers fixed time access to individual elements in any order.
constexpr iterator end() noexcept
constexpr iterator begin() noexcept
constexpr void assign(size_type __n, const value_type &__val)
constexpr void swap(vector &__x) noexcept
constexpr bool empty() const noexcept
constexpr allocator_type get_allocator() const noexcept
constexpr size_type size() const noexcept
constexpr reference operator[](size_type __n) noexcept
constexpr size_type max_size() const noexcept