31 #if __cplusplus >= 202002L 38 namespace 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,
61 _RegexExecutorPolicy __policy,
64 template<
typename,
typename,
typename,
bool>
67 template<
typename _Tp>
70 template<
typename _Tp>
71 struct __is_contiguous_iter<_Tp*> :
true_type { };
73 template<
typename _Tp,
typename _Cont>
74 struct __is_contiguous_iter<
__gnu_cxx::__normal_iterator<_Tp*, _Cont>>
78 _GLIBCXX_BEGIN_NAMESPACE_CXX11
98 template<
typename _Ch_type>
102 typedef _Ch_type char_type;
109 typedef std::ctype_base::mask _BaseType;
111 unsigned char _M_extended;
112 static constexpr
unsigned char _S_under = 1 << 0;
113 static constexpr
unsigned char _S_valid_mask = 0x1;
115 constexpr _RegexMask(_BaseType
__base = 0,
116 unsigned char __extended = 0)
117 : _M_base(
__base), _M_extended(__extended)
123 return _RegexMask(_M_base & __other._M_base,
124 _M_extended & __other._M_extended);
130 return _RegexMask(_M_base | __other._M_base,
131 _M_extended | __other._M_extended);
137 return _RegexMask(_M_base ^ __other._M_base,
138 _M_extended ^ __other._M_extended);
143 {
return _RegexMask(~_M_base, ~_M_extended); }
146 operator&=(_RegexMask __other)
147 {
return *
this = (*this) & __other; }
150 operator|=(_RegexMask __other)
151 {
return *
this = (*this) | __other; }
154 operator^=(_RegexMask __other)
155 {
return *
this = (*this) ^ __other; }
158 operator==(_RegexMask __other)
const 160 return (_M_extended & _S_valid_mask)
161 == (__other._M_extended & _S_valid_mask)
162 && _M_base == __other._M_base;
165 #if __cpp_impl_three_way_comparison < 201907L 167 operator!=(_RegexMask __other)
const 168 {
return !((*this) == __other); }
173 typedef _RegexMask char_class_type;
193 {
return string_type::traits_type::length(__p); }
219 const __ctype_type& __fctyp(use_facet<__ctype_type>(_M_locale));
220 return __fctyp.tolower(__c);
243 template<
typename _Fwd_iter>
248 const __collate_type& __fclt(use_facet<__collate_type>(_M_locale));
250 return __fclt.transform(__s.
data(), __s.
data() + __s.
size());
267 template<
typename _Fwd_iter>
273 const auto& __fclt = use_facet<collate<char_type>>(_M_locale);
283 const auto __p =
const_cast<char_type*
>(__s.
c_str());
284 const auto __pend = __p + __s.
size();
290 __fctyp.tolower(__p, __pend);
294 __ret = __fclt.transform(__p, __pend);
314 template<
typename _Fwd_iter>
355 template<
typename _Fwd_iter>
358 bool __icase =
false)
const;
373 isctype(_Ch_type __c, char_class_type __f)
const;
386 value(_Ch_type __ch,
int __radix)
const;
402 std::swap(_M_locale, __loc);
412 {
return _M_locale; }
415 locale_type _M_locale;
439 template<
typename _Ch_type,
typename _Rx_traits = regex_traits<_Ch_type>>
443 static_assert(is_same<_Ch_type, typename _Rx_traits::char_type>::value,
444 "regex traits class must have the same char_type");
447 typedef _Ch_type value_type;
448 typedef _Rx_traits traits_type;
449 typedef typename traits_type::string_type string_type;
451 typedef typename traits_type::locale_type locale_type;
468 #if __cplusplus >= 201703L || !defined __STRICT_ANSI__ 479 : _M_flags(ECMAScript), _M_loc(), _M_automaton(
nullptr)
495 { _M_compile(__p, __p + _Rx_traits::length(__p), __f); }
512 __glibcxx_requires_string_len(__p, __len);
513 _M_compile(__p, __p + __len, __f);
539 template<
typename _Ch_traits,
typename _Ch_alloc>
544 { _M_compile(__s.data(), __s.data() + __s.size(), __f); }
559 template<
typename _FwdIter>
562 { this->
assign(__first, __last, __f); }
573 { _M_compile(__l.begin(), __l.end(), __f); }
602 {
return this->
assign(__p); }
614 {
return this->
assign(__l); }
622 template<
typename _Ch_traits,
typename _Alloc>
625 {
return this->
assign(__s); }
635 {
return *
this = __rhs; }
662 _M_compile(__p, __p + _Rx_traits::length(__p), __flags);
684 _M_compile(__p, __p + __len, __flags);
699 template<
typename _Ch_traits,
typename _Alloc>
704 _M_compile(__s.
data(), __s.
data() + __s.
size(), __flags);
721 template<
typename _InputIterator>
723 assign(_InputIterator __first, _InputIterator __last,
726 #if __cpp_if_constexpr >= 201606L 728 if constexpr (__detail::__is_contiguous_iter<_InputIterator>::value
729 && is_same_v<_ValT, value_type>)
731 __glibcxx_requires_valid_range(__first, __last);
732 if constexpr (is_pointer_v<_InputIterator>)
733 _M_compile(__first, __last, __flags);
735 _M_compile(__first.base(), __last.base(), __flags);
739 this->
assign(string_type(__first, __last), __flags);
757 _M_compile(__l.begin(), __l.end(), __flags);
770 return _M_automaton->_M_sub_count() - 1;
791 std::swap(__loc, _M_loc);
792 _M_automaton.reset();
813 std::swap(_M_flags, __rhs._M_flags);
814 std::swap(_M_loc, __rhs._M_loc);
815 std::swap(_M_automaton, __rhs._M_automaton);
818 #ifdef _GLIBCXX_DEBUG 821 { _M_automaton->_M_dot(__ostr); }
828 _M_compile(
const _Ch_type* __first,
const _Ch_type* __last,
831 __detail::_Compiler<_Rx_traits> __c(__first, __last, _M_loc, __f);
832 _M_automaton = __c._M_get_nfa();
836 template<
typename _Bp,
typename _Ap,
typename _Cp,
typename _Rp>
838 __detail::__regex_algo_impl(_Bp, _Bp, match_results<_Bp, _Ap>&,
839 const basic_regex<_Cp, _Rp>&,
841 __detail::_RegexExecutorPolicy,
bool);
843 template<
typename,
typename,
typename,
bool>
844 friend class __detail::_Executor;
848 _AutomatonPtr _M_automaton;
851 #if ! __cpp_inline_variables 852 template<
typename _Ch,
typename _Tr>
856 template<
typename _Ch,
typename _Tr>
860 template<
typename _Ch,
typename _Tr>
864 template<
typename _Ch,
typename _Tr>
868 template<
typename _Ch,
typename _Tr>
872 template<
typename _Ch,
typename _Tr>
876 template<
typename _Ch,
typename _Tr>
880 template<
typename _Ch,
typename _Tr>
884 template<
typename _Ch,
typename _Tr>
888 template<
typename _Ch,
typename _Tr>
893 #if __cpp_deduction_guides >= 201606 894 template<
typename _ForwardIterator>
895 basic_regex(_ForwardIterator, _ForwardIterator,
897 -> basic_regex<
typename iterator_traits<_ForwardIterator>::value_type>;
903 #ifdef _GLIBCXX_USE_WCHAR_T 916 template<
typename _Ch_type,
typename _Rx_traits>
920 { __lhs.swap(__rhs); }
941 template<
typename _BiIter>
950 typedef typename __iter_traits::value_type value_type;
951 typedef typename __iter_traits::difference_type difference_type;
952 typedef _BiIter iterator;
955 _GLIBCXX_DOXYGEN_ONLY(iterator first; iterator second;)
959 constexpr
sub_match() noexcept : matched() { }
964 {
return this->matched ?
std::distance(this->first, this->second) : 0; }
1003 {
return this->_M_str().compare(__s._M_str()); }
1017 {
return this->_M_str().compare(__s); }
1021 {
return this->_M_str().compare(__s); }
1027 _M_compare(
const value_type* __s,
size_t __n)
const 1028 {
return this->_M_str().compare({__s, __n}); }
1038 std::swap(matched, __s.matched);
1043 struct __string_view
1045 using traits_type =
typename string_type::traits_type;
1047 __string_view() =
default;
1049 __string_view(
const value_type* __s,
size_t __n) noexcept
1050 : _M_data(__s), _M_len(__n) { }
1052 __string_view(
const value_type* __s) noexcept
1053 : _M_data(__s), _M_len(traits_type::length(__s)) { }
1055 __string_view(
const string_type& __s) noexcept
1056 : _M_data(__s.data()), _M_len(__s.length()) { }
1059 compare(__string_view __s)
const noexcept
1061 if (
const size_t __n =
std::min(_M_len, __s._M_len))
1062 if (
int __ret = traits_type::compare(_M_data, __s._M_data, __n))
1065 const difference_type __diff = _M_len - __s._M_len;
1066 if (__diff > __limits::__max)
1067 return __limits::__max;
1068 if (__diff < __limits::__min)
1069 return __limits::__min;
1070 return static_cast<int>(__diff);
1074 const value_type* _M_data =
nullptr;
1079 template<
typename _Iter = _BiIter>
1080 __enable_if_t<__detail::__is_contiguous_iter<_Iter>::value,
1082 _M_str() const noexcept
1085 if (
size_t __len = this->second - this->first)
1091 template<
typename _Iter = _BiIter>
1092 __enable_if_t<!__detail::__is_contiguous_iter<_Iter>::value,
1105 #ifdef _GLIBCXX_USE_WCHAR_T 1123 template<
typename _BiIter>
1126 {
return __lhs.
compare(__rhs) == 0; }
1128 #if __cpp_lib_three_way_comparison 1136 template<
typename _BiIter>
1140 noexcept(__detail::__is_contiguous_iter<_BiIter>::value)
1143 return __detail::__char_traits_cmp_cat<_Tr>(__lhs.compare(__rhs));
1152 template<
typename _BiIter>
1155 {
return __lhs.
compare(__rhs) != 0; }
1163 template<
typename _BiIter>
1165 operator<(const sub_match<_BiIter>& __lhs,
const sub_match<_BiIter>& __rhs)
1166 {
return __lhs.
compare(__rhs) < 0; }
1174 template<
typename _BiIter>
1176 operator<=(const sub_match<_BiIter>& __lhs,
const sub_match<_BiIter>& __rhs)
1177 {
return __lhs.
compare(__rhs) <= 0; }
1185 template<
typename _BiIter>
1187 operator>=(
const sub_match<_BiIter>& __lhs,
const sub_match<_BiIter>& __rhs)
1188 {
return __lhs.compare(__rhs) >= 0; }
1196 template<
typename _BiIter>
1198 operator>(
const sub_match<_BiIter>& __lhs,
const sub_match<_BiIter>& __rhs)
1199 {
return __lhs.compare(__rhs) > 0; }
1200 #endif // three-way comparison 1205 template<
typename _Bi_iter,
typename _Ch_traits,
typename _Ch_alloc>
1206 using __sub_match_string = basic_string<
1207 typename iterator_traits<_Bi_iter>::value_type,
1208 _Ch_traits, _Ch_alloc>;
1211 #if ! __cpp_lib_three_way_comparison 1219 template<
typename _Bi_iter,
typename _Ch_traits,
typename _Ch_alloc>
1221 operator==(
const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
1222 const sub_match<_Bi_iter>& __rhs)
1223 {
return __rhs._M_compare(__lhs.data(), __lhs.size()) == 0; }
1232 template<
typename _Bi_iter,
typename _Ch_traits,
typename _Ch_alloc>
1234 operator!=(
const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
1235 const sub_match<_Bi_iter>& __rhs)
1236 {
return !(__lhs == __rhs); }
1244 template<
typename _Bi_iter,
typename _Ch_traits,
typename _Ch_alloc>
1246 operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
1247 const sub_match<_Bi_iter>& __rhs)
1248 {
return __rhs._M_compare(__lhs.data(), __lhs.size()) > 0; }
1256 template<
typename _Bi_iter,
typename _Ch_traits,
typename _Ch_alloc>
1258 operator>(
const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
1259 const sub_match<_Bi_iter>& __rhs)
1260 {
return __rhs < __lhs; }
1268 template<
typename _Bi_iter,
typename _Ch_traits,
typename _Ch_alloc>
1270 operator>=(
const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
1271 const sub_match<_Bi_iter>& __rhs)
1272 {
return !(__lhs < __rhs); }
1280 template<
typename _Bi_iter,
typename _Ch_traits,
typename _Ch_alloc>
1282 operator<=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
1283 const sub_match<_Bi_iter>& __rhs)
1284 {
return !(__rhs < __lhs); }
1285 #endif // three-way comparison 1294 template<
typename _Bi_iter,
typename _Ch_traits,
typename _Ch_alloc>
1297 const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
1298 {
return __lhs._M_compare(__rhs.data(), __rhs.size()) == 0; }
1300 #if __cpp_lib_three_way_comparison 1308 template<
typename _Bi_iter,
typename _Ch_traits,
typename _Alloc>
1311 const __sub_match_string<_Bi_iter, _Ch_traits, _Alloc>& __rhs)
1312 noexcept(__detail::__is_contiguous_iter<_Bi_iter>::value)
1314 return __detail::__char_traits_cmp_cat<_Ch_traits>(
1315 __lhs._M_compare(__rhs.data(), __rhs.size()));
1325 template<
typename _Bi_iter,
typename _Ch_traits,
typename _Ch_alloc>
1328 const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
1329 {
return !(__lhs == __rhs); }
1337 template<
typename _Bi_iter,
typename _Ch_traits,
typename _Ch_alloc>
1339 operator<(const sub_match<_Bi_iter>& __lhs,
1340 const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
1341 {
return __lhs._M_compare(__rhs.data(), __rhs.size()) < 0; }
1349 template<
typename _Bi_iter,
typename _Ch_traits,
typename _Ch_alloc>
1351 operator>(
const sub_match<_Bi_iter>& __lhs,
1352 const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
1353 {
return __rhs < __lhs; }
1361 template<
typename _Bi_iter,
typename _Ch_traits,
typename _Ch_alloc>
1364 const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
1365 {
return !(__lhs < __rhs); }
1373 template<
typename _Bi_iter,
typename _Ch_traits,
typename _Ch_alloc>
1375 operator<=(const sub_match<_Bi_iter>& __lhs,
1376 const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
1377 {
return !(__rhs < __lhs); }
1386 template<
typename _Bi_iter>
1388 operator==(
typename iterator_traits<_Bi_iter>::value_type
const* __lhs,
1389 const sub_match<_Bi_iter>& __rhs)
1390 {
return __rhs.compare(__lhs) == 0; }
1399 template<
typename _Bi_iter>
1401 operator!=(
typename iterator_traits<_Bi_iter>::value_type
const* __lhs,
1402 const sub_match<_Bi_iter>& __rhs)
1403 {
return !(__lhs == __rhs); }
1411 template<
typename _Bi_iter>
1413 operator<(typename iterator_traits<_Bi_iter>::value_type
const* __lhs,
1414 const sub_match<_Bi_iter>& __rhs)
1415 {
return __rhs.compare(__lhs) > 0; }
1423 template<
typename _Bi_iter>
1425 operator>(
typename iterator_traits<_Bi_iter>::value_type
const* __lhs,
1426 const sub_match<_Bi_iter>& __rhs)
1427 {
return __rhs < __lhs; }
1435 template<
typename _Bi_iter>
1437 operator>=(
typename iterator_traits<_Bi_iter>::value_type
const* __lhs,
1438 const sub_match<_Bi_iter>& __rhs)
1439 {
return !(__lhs < __rhs); }
1447 template<
typename _Bi_iter>
1449 operator<=(typename iterator_traits<_Bi_iter>::value_type
const* __lhs,
1450 const sub_match<_Bi_iter>& __rhs)
1451 {
return !(__rhs < __lhs); }
1452 #endif // three-way comparison 1461 template<
typename _Bi_iter>
1465 {
return __lhs.
compare(__rhs) == 0; }
1467 #if __cpp_lib_three_way_comparison 1476 template<
typename _Bi_iter>
1480 noexcept(__detail::__is_contiguous_iter<_Bi_iter>::value)
1483 return __detail::__char_traits_cmp_cat<_Tr>(__lhs.compare(__rhs));
1493 template<
typename _Bi_iter>
1497 {
return !(__lhs == __rhs); }
1505 template<
typename _Bi_iter>
1507 operator<(const sub_match<_Bi_iter>& __lhs,
1508 typename iterator_traits<_Bi_iter>::value_type
const* __rhs)
1509 {
return __lhs.compare(__rhs) < 0; }
1517 template<
typename _Bi_iter>
1519 operator>(
const sub_match<_Bi_iter>& __lhs,
1520 typename iterator_traits<_Bi_iter>::value_type
const* __rhs)
1521 {
return __rhs < __lhs; }
1529 template<
typename _Bi_iter>
1532 typename iterator_traits<_Bi_iter>::value_type
const* __rhs)
1533 {
return !(__lhs < __rhs); }
1541 template<
typename _Bi_iter>
1543 operator<=(const sub_match<_Bi_iter>& __lhs,
1544 typename iterator_traits<_Bi_iter>::value_type
const* __rhs)
1545 {
return !(__rhs < __lhs); }
1554 template<
typename _Bi_iter>
1556 operator==(
typename iterator_traits<_Bi_iter>::value_type
const& __lhs,
1557 const sub_match<_Bi_iter>& __rhs)
1567 template<
typename _Bi_iter>
1569 operator!=(
typename iterator_traits<_Bi_iter>::value_type
const& __lhs,
1570 const sub_match<_Bi_iter>& __rhs)
1571 {
return !(__lhs == __rhs); }
1580 template<
typename _Bi_iter>
1582 operator<(typename iterator_traits<_Bi_iter>::value_type
const& __lhs,
1583 const sub_match<_Bi_iter>& __rhs)
1593 template<
typename _Bi_iter>
1595 operator>(
typename iterator_traits<_Bi_iter>::value_type
const& __lhs,
1596 const sub_match<_Bi_iter>& __rhs)
1597 {
return __rhs < __lhs; }
1606 template<
typename _Bi_iter>
1608 operator>=(
typename iterator_traits<_Bi_iter>::value_type
const& __lhs,
1609 const sub_match<_Bi_iter>& __rhs)
1610 {
return !(__lhs < __rhs); }
1619 template<
typename _Bi_iter>
1621 operator<=(typename iterator_traits<_Bi_iter>::value_type
const& __lhs,
1622 const sub_match<_Bi_iter>& __rhs)
1623 {
return !(__rhs < __lhs); }
1624 #endif // three-way comparison 1633 template<
typename _Bi_iter>
1639 #if __cpp_lib_three_way_comparison 1649 template<
typename _Bi_iter>
1653 noexcept(__detail::__is_contiguous_iter<_Bi_iter>::value)
1656 return __detail::__char_traits_cmp_cat<_Tr>(
1667 template<
typename _Bi_iter>
1671 {
return !(__lhs == __rhs); }
1680 template<
typename _Bi_iter>
1682 operator<(const sub_match<_Bi_iter>& __lhs,
1683 typename iterator_traits<_Bi_iter>::value_type
const& __rhs)
1693 template<
typename _Bi_iter>
1695 operator>(
const sub_match<_Bi_iter>& __lhs,
1696 typename iterator_traits<_Bi_iter>::value_type
const& __rhs)
1697 {
return __rhs < __lhs; }
1706 template<
typename _Bi_iter>
1709 typename iterator_traits<_Bi_iter>::value_type
const& __rhs)
1710 {
return !(__lhs < __rhs); }
1719 template<
typename _Bi_iter>
1721 operator<=(const sub_match<_Bi_iter>& __lhs,
1722 typename iterator_traits<_Bi_iter>::value_type
const& __rhs)
1723 {
return !(__rhs < __lhs); }
1724 #endif // three-way comparison 1734 template<
typename _Ch_type,
typename _Ch_traits,
typename _Bi_iter>
1736 basic_ostream<_Ch_type, _Ch_traits>&
1737 operator<<(basic_ostream<_Ch_type, _Ch_traits>& __os,
1739 {
return __os << __m.str(); }
1768 template<
typename _Bi_iter,
1771 :
private std::vector<sub_match<_Bi_iter>, _Alloc>
1792 typedef _GLIBCXX_STD_C::vector<sub_match<_Bi_iter>, _Alloc> _Unchecked;
1802 typedef const value_type& const_reference;
1803 typedef value_type& reference;
1804 typedef typename _Base_type::const_iterator const_iterator;
1806 typedef typename __iter_traits::difference_type difference_type;
1808 typedef _Alloc allocator_type;
1809 typedef typename __iter_traits::value_type char_type;
1908 _GLIBCXX_NODISCARD
bool 1929 {
return (*
this)[__sub].length(); }
1956 str(size_type __sub = 0)
const 1973 __glibcxx_assert(
ready() );
1974 return __sub <
size()
1976 : _M_unmatched_sub();
1990 __glibcxx_assert(
ready() );
1991 return !
empty() ? _M_prefix() : _M_unmatched_sub();
2005 __glibcxx_assert(
ready() );
2006 return !
empty() ? _M_suffix() : _M_unmatched_sub();
2021 {
return this->
begin(); }
2035 {
return this->
end(); }
2052 template<
typename _Out_iter>
2054 format(_Out_iter __out,
const char_type* __fmt_first,
2055 const char_type* __fmt_last,
2061 template<
typename _Out_iter,
typename _St,
typename _Sa>
2073 template<
typename _St,
typename _Sa>
2110 {
return _Base_type::get_allocator(); }
2127 swap(_M_begin, __that._M_begin);
2132 template<
typename,
typename,
typename>
2137 template<
typename,
typename,
typename,
bool>
2140 template<
typename _Bp,
typename _Ap,
typename _Cp,
typename _Rp>
2145 __detail::_RegexExecutorPolicy,
bool);
2150 _M_resize(
unsigned int __size)
2155 _M_establish_failed_match(_Bi_iter __end)
2157 sub_match<_Bi_iter> __sm;
2158 __sm.first = __sm.second = __end;
2163 _M_unmatched_sub()
const 2166 sub_match<_Bi_iter>&
2174 sub_match<_Bi_iter>&
2182 sub_match<_Bi_iter>&
2186 _Bi_iter _M_begin {};
2190 typedef match_results<const char*> cmatch;
2191 typedef match_results<string::const_iterator> smatch;
2192 #ifdef _GLIBCXX_USE_WCHAR_T 2193 typedef match_results<const wchar_t*> wcmatch;
2194 typedef match_results<wstring::const_iterator> wsmatch;
2206 template<
typename _Bi_iter,
typename _Alloc>
2225 #if ! __cpp_lib_three_way_comparison 2233 template<
typename _Bi_iter,
class _Alloc>
2237 {
return !(__m1 == __m2); }
2250 template<
typename _Bi_iter,
typename _Alloc>
2254 { __lhs.swap(__rhs); }
2256 _GLIBCXX_END_NAMESPACE_CXX11
2280 template<
typename _Bi_iter,
typename _Alloc,
2281 typename _Ch_type,
typename _Rx_traits>
2290 return __detail::__regex_algo_impl(__s, __e, __m, __re, __flags,
2291 __detail::_RegexExecutorPolicy::_S_auto,
true);
2308 template<
typename _Bi_iter,
typename _Ch_type,
typename _Rx_traits>
2316 return regex_match(__first, __last, __what, __re, __flags);
2333 template<
typename _Ch_type,
typename _Alloc,
typename _Rx_traits>
2340 {
return regex_match(__s, __s + _Rx_traits::length(__s), __m, __re, __f); }
2356 template<
typename _Ch_traits,
typename _Ch_alloc,
2357 typename _Alloc,
typename _Ch_type,
typename _Rx_traits>
2361 _Ch_traits, _Ch_alloc>::const_iterator, _Alloc>& __m,
2370 template<
typename _Ch_traits,
typename _Ch_alloc,
2371 typename _Alloc,
typename _Ch_type,
typename _Rx_traits>
2373 regex_match(
const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>&&,
2374 match_results<
typename basic_string<_Ch_type,
2375 _Ch_traits, _Ch_alloc>::const_iterator, _Alloc>&,
2376 const basic_regex<_Ch_type, _Rx_traits>&,
2393 template<
typename _Ch_type,
class _Rx_traits>
2399 {
return regex_match(__s, __s + _Rx_traits::length(__s), __re, __f); }
2414 template<
typename _Ch_traits,
typename _Str_allocator,
2415 typename _Ch_type,
typename _Rx_traits>
2437 template<
typename _Bi_iter,
typename _Alloc,
2438 typename _Ch_type,
typename _Rx_traits>
2446 return __detail::__regex_algo_impl(__s, __e, __m, __re, __flags,
2447 __detail::_RegexExecutorPolicy::_S_auto,
false);
2461 template<
typename _Bi_iter,
typename _Ch_type,
typename _Rx_traits>
2469 return regex_search(__first, __last, __what, __re, __flags);
2484 template<
typename _Ch_type,
class _Alloc,
class _Rx_traits>
2491 {
return regex_search(__s, __s + _Rx_traits::length(__s), __m, __e, __f); }
2503 template<
typename _Ch_type,
typename _Rx_traits>
2509 {
return regex_search(__s, __s + _Rx_traits::length(__s), __e, __f); }
2521 template<
typename _Ch_traits,
typename _String_allocator,
2522 typename _Ch_type,
typename _Rx_traits>
2525 _String_allocator>& __s,
2529 {
return regex_search(__s.begin(), __s.end(), __e, __flags); }
2543 template<
typename _Ch_traits,
typename _Ch_alloc,
2544 typename _Alloc,
typename _Ch_type,
2545 typename _Rx_traits>
2549 _Ch_traits, _Ch_alloc>::const_iterator, _Alloc>& __m,
2558 template<
typename _Ch_traits,
typename _Ch_alloc,
2559 typename _Alloc,
typename _Ch_type,
2560 typename _Rx_traits>
2562 regex_search(
const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>&&,
2563 match_results<
typename basic_string<_Ch_type,
2564 _Ch_traits, _Ch_alloc>::const_iterator, _Alloc>&,
2565 const basic_regex<_Ch_type, _Rx_traits>&,
2572 template<
typename _Out_iter,
typename _Bi_iter,
2573 typename _Rx_traits,
typename _Ch_type>
2575 __regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
2576 const basic_regex<_Ch_type, _Rx_traits>& __e,
2577 const _Ch_type* __fmt,
size_t __len,
2594 template<
typename _Out_iter,
typename _Bi_iter,
2595 typename _Rx_traits,
typename _Ch_type,
2596 typename _St,
typename _Sa>
2604 return std::__regex_replace(__out, __first, __last, __e, __fmt.
c_str(),
2605 __fmt.
length(), __flags);
2621 template<
typename _Out_iter,
typename _Bi_iter,
2622 typename _Rx_traits,
typename _Ch_type>
2626 const _Ch_type* __fmt,
2630 return std::__regex_replace(__out, __first, __last, __e, __fmt,
2647 template<
typename _Rx_traits,
typename _Ch_type,
2648 typename _St,
typename _Sa,
typename _Fst,
typename _Fsa>
2649 inline basic_string<_Ch_type, _St, _Sa>
2658 __s.
begin(), __s.
end(), __e, __fmt, __flags);
2673 template<
typename _Rx_traits,
typename _Ch_type,
2674 typename _St,
typename _Sa>
2675 inline basic_string<_Ch_type, _St, _Sa>
2678 const _Ch_type* __fmt,
2684 __s.
begin(), __s.
end(), __e, __fmt, __flags);
2699 template<
typename _Rx_traits,
typename _Ch_type,
2700 typename _St,
typename _Sa>
2701 inline basic_string<_Ch_type>
2711 __e, __fmt, __flags);
2726 template<
typename _Rx_traits,
typename _Ch_type>
2727 inline basic_string<_Ch_type>
2730 const _Ch_type* __fmt,
2737 __e, __fmt, __flags);
2743 _GLIBCXX_BEGIN_NAMESPACE_CXX11
2753 template<
typename _Bi_iter,
2754 typename _Ch_type =
typename iterator_traits<_Bi_iter>::value_type,
2755 typename _Rx_traits = regex_traits<_Ch_type> >
2761 typedef std::ptrdiff_t difference_type;
2765 #if __cplusplus > 201703L 2785 : _M_begin(__a), _M_end(__b), _M_pregex(&__re), _M_flags(__m), _M_match()
2787 if (!
regex_search(_M_begin, _M_end, _M_match, *_M_pregex, _M_flags))
2812 #if __cplusplus >= 202002L 2816 {
return _M_pregex ==
nullptr; }
2819 #if __cpp_impl_three_way_comparison < 201907L 2825 {
return !(*
this == __rhs); }
2833 {
return _M_match; }
2840 {
return &_M_match; }
2860 _Bi_iter _M_begin {};
2862 const regex_type* _M_pregex =
nullptr;
2864 match_results<_Bi_iter> _M_match;
2867 typedef regex_iterator<const char*> cregex_iterator;
2868 typedef regex_iterator<string::const_iterator> sregex_iterator;
2869 #ifdef _GLIBCXX_USE_WCHAR_T 2870 typedef regex_iterator<const wchar_t*> wcregex_iterator;
2871 typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
2885 template<
typename _Bi_iter,
2886 typename _Ch_type =
typename iterator_traits<_Bi_iter>::value_type,
2887 typename _Rx_traits = regex_traits<_Ch_type> >
2893 typedef std::ptrdiff_t difference_type;
2897 #if __cplusplus > 201703L 2910 : _M_position(), _M_subs(), _M_suffix(), _M_n(0), _M_result(nullptr),
2935 : _M_position(__a, __b, __re, __m), _M_subs(1, __submatch), _M_n(0)
2936 { _M_init(__a, __b); }
2952 : _M_position(__a, __b, __re, __m), _M_subs(__submatches), _M_n(0)
2953 { _M_init(__a, __b); }
2969 : _M_position(__a, __b, __re, __m), _M_subs(__submatches), _M_n(0)
2970 { _M_init(__a, __b); }
2981 template<std::
size_t _Nm>
2984 const int (&__submatches)[_Nm],
2987 : _M_position(__a, __b, __re, __m),
2988 _M_subs(__submatches, __submatches + _Nm), _M_n(0)
2989 { _M_init(__a, __b); }
3004 template <std::
size_t _Nm>
3015 : _M_position(__rhs._M_position), _M_subs(__rhs._M_subs),
3016 _M_suffix(__rhs._M_suffix), _M_n(__rhs._M_n), _M_has_m1(__rhs._M_has_m1)
3017 { _M_normalize_result(); }
3032 #if __cplusplus >= 202002L 3036 {
return _M_end_of_seq(); }
3039 #if __cpp_impl_three_way_comparison < 201907L 3045 {
return !(*
this == __rhs); }
3053 {
return *_M_result; }
3060 {
return _M_result; }
3083 _M_init(_Bi_iter __a, _Bi_iter __b);
3086 _M_current_match()
const 3088 if (_M_subs[_M_n] == -1)
3089 return (*_M_position).prefix();
3091 return (*_M_position)[_M_subs[_M_n]];
3095 _M_end_of_seq() const noexcept
3096 {
return _M_result ==
nullptr; }
3100 _M_normalize_result()
3102 if (_M_position != _Position())
3103 _M_result = &_M_current_match();
3105 _M_result = &_M_suffix;
3107 _M_result =
nullptr;
3110 _Position _M_position;
3112 value_type _M_suffix;
3114 const value_type* _M_result;
3126 #ifdef _GLIBCXX_USE_WCHAR_T 3136 _GLIBCXX_END_NAMESPACE_CXX11
3137 _GLIBCXX_END_NAMESPACE_VERSION
basic_regex(initializer_list< _Ch_type > __l, flag_type __f=ECMAScript)
Constructs a basic regular expression from an initializer list.
const _Facet & use_facet(const locale &__loc)
Return a facet.use_facet looks for and returns a reference to a facet of type Facet where Facet is th...
regex_token_iterator< const wchar_t * > wcregex_token_iterator
Token iterator for C-style NULL-terminated wide strings.
size_type max_size() const noexcept
Gets the number of matches and submatches.
const_iterator cbegin() const noexcept
Gets an iterator to the start of the sub_match collection.
int compare(const string_type &__s) const
Compares this sub_match to a string.
constexpr syntax_option_type basic
regex_token_iterator()
Default constructs a regex_token_iterator.
const value_type * operator->() const noexcept
Selects a regex_iterator member.
constexpr syntax_option_type extended
locale_type getloc() const
Gets a copy of the current locale in use by the regex_traits object.
regex_token_iterator & operator++()
Increments a regex_token_iterator.
constexpr bitset< _Nb > operator &(const bitset< _Nb > &__x, const bitset< _Nb > &__y) noexcept
Global bitwise operations on bitsets.
regex_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type &__re, regex_constants::match_flag_type __m=regex_constants::match_default)
Forward iterators support a superset of input iterator operations.
constexpr void swap(vector &__x) noexcept
Swaps data with another vector.
void swap(match_results &__that) noexcept
Swaps the contents of two match_results.
sub_match< string::const_iterator > ssub_match
Standard regex submatch over a standard string.
The standard allocator, as per C++03 [20.4.1].
string_type str(size_type __sub=0) const
Gets the match or submatch converted to a string type.
constexpr match_flag_type format_default
unsigned int mark_count() const noexcept
Gets the number of marked subexpressions within the regular expression.
GNU extensions for public use.
constexpr void assign(size_type __n, const value_type &__val)
Assigns a given value to a vector.
constexpr syntax_option_type grep
_Out_iter format(_Out_iter __out, const basic_string< char_type, _St, _Sa > &__fmt, match_flag_type __flags=regex_constants::format_default) const
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...
regex_iterator()=default
Provides a singular iterator, useful for indicating one-past-the-end of a range.
The results of a match or search operation.
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...
const value_type * operator->() const
Selects a regex_token_iterator member.
constexpr bool equal(_IIter1 __first1, _IIter1 __last1, _IIter2 __first2, _IIter2 __last2, _BinaryPredicate __binary_pred)
Tests a range for element-wise equality.
constexpr syntax_option_type nosubs
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.
~basic_regex()
Destroys a basic regular expression.
Traits class for iterators.
regex_iterator operator++(int)
Postincrements a regex_iterator.
static std::size_t length(const char_type *__p)
Gives the length of a C-style string starting at __p.
difference_type length() const noexcept
Gets the length of the matching sequence.
Basis for explicit traits specializations.
regex_traits()
Constructs a default traits object.
basic_regex & operator=(const basic_string< _Ch_type, _Ch_traits, _Alloc > &__s)
Replaces a regular expression with a new one constructed from a string.
bool empty() const noexcept
Indicates if the match_results contains no results.
const _CharT * data() const noexcept
Return const pointer to contents.
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...
Base class for all library exceptions.
syntax_option_type
This is a bitmask type indicating how to interpret the regex.
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)
constexpr bool operator>(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
string_type str() const
Gets the matching sequence as a string.
match_flag_type
This is a bitmask type indicating regex matching rules.
regex_token_iterator< wstring::const_iterator > wsregex_token_iterator
Token iterator for standard wide-character strings.
constexpr syntax_option_type awk
constexpr _Iterator __base(_Iterator __it)
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...
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.
constexpr back_insert_iterator< _Container > back_inserter(_Container &__x)
constexpr syntax_option_type optimize
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)
constexpr const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
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 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)
allocator_type get_allocator() const noexcept
Gets a copy of the allocator.
const_iterator end() const noexcept
Gets an iterator to one-past-the-end of the collection.
constexpr bitset< _Nb > operator^(const bitset< _Nb > &__x, const bitset< _Nb > &__y) noexcept
Global bitwise operations on bitsets.
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...
constexpr iterator begin() noexcept
bool operator==(const sub_match< _BiIter > &__lhs, const sub_match< _BiIter > &__rhs)
Tests the equivalence of two regular expression submatches.
string_type transform(_Fwd_iter __first, _Fwd_iter __last) const
Gets a sort key for a character sequence.
basic_regex & operator=(const basic_regex &)=default
Assigns one regular expression to another.
char_type translate_nocase(char_type __c) const
Translates a character into a case-insensitive equivalent.
locale_type imbue(locale_type __loc)
Imbues the regex_traits object with a copy of a new locale.
match_results()
Constructs a default match_results container.
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_iterator cend() const noexcept
Gets an iterator to one-past-the-end of the collection.
constexpr syntax_option_type egrep
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
constexpr bitset< _Nb > operator|(const bitset< _Nb > &__x, const bitset< _Nb > &__y) noexcept
Global bitwise operations on bitsets.
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.
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
void swap(match_results< _Bi_iter, _Alloc > &__lhs, match_results< _Bi_iter, _Alloc > &__rhs) noexcept
Swaps two match results.
Struct holding two objects of arbitrary type.
const_reference prefix() const
Gets a sub_match representing the match prefix.
const_reference suffix() const
Gets a sub_match representing the match suffix.
match_results(match_results &&__m, const _Alloc &__a) noexcept(noexcept(_Base_type(std::move(__m), __a)))
Constructs a default match_results container.
basic_regex & assign(_InputIterator __first, _InputIterator __last, flag_type __flags=ECMAScript)
Assigns a new regular expression to a regex object.
difference_type position(size_type __sub=0) const
Gets the offset of the beginning of the indicated submatch.
constexpr size_type max_size() const noexcept
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)
size_type size() const noexcept
Gets the number of matches and submatches.
regex_token_iterator operator++(int)
Postincrements a regex_token_iterator.
constexpr syntax_option_type ECMAScript
constexpr size_type size() const noexcept
constexpr match_flag_type match_default
const value_type & operator*() const noexcept
Dereferences a regex_iterator.
Takes a regex and an input string and does the matching.
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...
string_type lookup_collatename(_Fwd_iter __first, _Fwd_iter __last) const
Gets a collation element by name.
string_type transform_primary(_Fwd_iter __first, _Fwd_iter __last) const
Gets a sort key for a character sequence, independent of case.
string_type format(const char_type *__fmt, match_flag_type __flags=regex_constants::format_default) const
constexpr syntax_option_type icase
bool operator==(const regex_token_iterator &__rhs) const
Compares a regex_token_iterator to another for equality.
typename _Size< _Alloc, difference_type >::type size_type
The allocator's size type.
basic_regex & operator=(initializer_list< _Ch_type > __l)
Replaces a regular expression with a new one constructed from an initializer list.
locale_type imbue(locale_type __loc)
Imbues the regular expression object with the given locale.
regex_iterator & operator++()
Increments a regex_iterator.
__bool_constant< false > false_type
The type used as a compile-time boolean with false value.
regex_token_iterator(const regex_token_iterator &__rhs)
Copy constructs a regex_token_iterator.
__numeric_traits_integer< _Tp > __int_traits
Convenience alias for __numeric_traits<integer-type>.
flag_type flags() const noexcept
Gets the flags used to construct the regular expression or in the last call to assign().
constexpr syntax_option_type multiline
ISO C++ entities toplevel namespace is std.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
basic_regex & assign(const basic_regex &__rhs) noexcept
Assigns one regular expression to another.
int compare(const sub_match &__s) const
Compares this and another matched sequence.
regex_token_iterator & operator=(const regex_token_iterator &__rhs)
Assigns a regex_token_iterator to another.
int compare(const value_type *__s) const
Compares this sub_match to a string.
constexpr bool empty() const noexcept
bool operator==(const match_results< _Bi_iter, _Alloc > &__m1, const match_results< _Bi_iter, _Alloc > &__m2)
Compares two match_results for equality.
int value(_Ch_type __ch, int __radix) const
Converts a digit to an int.
basic_regex< char > regex
Standard regular expressions.
Facet for localized string comparison.
sub_match< const wchar_t * > wcsub_match
Regex submatch over a C-style null-terminated wide string.
bool ready() const noexcept
Indicates if the match_results is ready.
Describes aspects of a regular expression.
__bool_constant< true > true_type
The type used as a compile-time boolean with true value.
A standard container which offers fixed time access to individual elements in any order...
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
basic_regex & assign(initializer_list< _Ch_type > __l, flag_type __flags=ECMAScript)
Assigns a new regular expression to a regex object.
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 regex_iterator &) const noexcept
Tests the equivalence of two regex iterators.
constexpr bool operator>=(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
Managing sequences of characters and character-like objects.
match_results(const _Alloc &__a) noexcept
Constructs a default match_results container.
regex_token_iterator< const char * > cregex_token_iterator
Token iterator for C-style NULL-terminated 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.
Container class for localization functionality.The locale class is first a class wrapper for C librar...
void swap(sub_match &__s) noexcept(__is_nothrow_swappable< _BiIter >::value)
Swap the values of two sub_match objects.
constexpr reference operator[](size_type __n) noexcept
Subscript access to the data contained in the vector.
_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...
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.
constexpr iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
locale_type getloc() const noexcept
Gets the locale currently imbued in the regular expression object.
const_iterator begin() const noexcept
Gets an iterator to the start of the sub_match collection.
constexpr syntax_option_type collate
regex_token_iterator< string::const_iterator > sregex_token_iterator
Token iterator for standard strings.
difference_type length(size_type __sub=0) const
Gets the length of the indicated submatch.
basic_regex & operator=(const _Ch_type *__p)
Replaces a regular expression with a new one constructed from a C-style null-terminated string...
sub_match< wstring::const_iterator > wssub_match
Regex submatch over a standard wide string.
const value_type & operator*() const
Dereferences a regex_token_iterator.
const_reference operator[](size_type __sub) const
Gets a sub_match reference for the match or submatch.
regex_iterator & operator=(const regex_iterator &)=default
Copy assigns one regex_iterator to another.
sub_match< const char * > csub_match
Standard regex submatch over a C-style null-terminated string.
Primary class template ctype facet.This template class defines classification and conversion function...
char_type translate(char_type __c) const
Performs the identity translation.
void swap(basic_regex &__rhs) noexcept
Swaps the contents of two regular expression objects.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
A smart pointer with reference-counted copy semantics.
bool isctype(_Ch_type __c, char_class_type __f) const
Determines if c is a member of an identified class.
constexpr iterator end() noexcept
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...
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)
basic_regex & assign(basic_regex &&__rhs) noexcept
Move-assigns one regular expression to another.
_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
basic_regex< wchar_t > wregex
Standard wide-character regular expressions.