1 // class template regex -*- C++ -*-
3 // Copyright (C) 2010-2013 Free Software Foundation, Inc.
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)
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.
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.
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/>.
27 * This is an internal header file, included by other library headers.
28 * Do not attempt to use it directly. @headername{regex}
31 namespace std
_GLIBCXX_VISIBILITY(default)
33 _GLIBCXX_BEGIN_NAMESPACE_VERSION
41 * @brief Class regex_traits. Describes aspects of a regular expression.
43 * A regular expression traits class that satisfies the requirements of
46 * The class %regex is parameterized around a set of related types and
47 * functions used to complete the definition of its semantics. This class
48 * satisfies the requirements of such a traits class.
50 template<typename _Ch_type
>
54 typedef _Ch_type char_type
;
55 typedef std::basic_string
<char_type
> string_type
;
56 typedef std::locale locale_type
;
57 typedef std::ctype_base::mask char_class_type
;
61 * @brief Constructs a default traits object.
66 * @brief Gives the length of a C-style string starting at @p __p.
68 * @param __p a pointer to the start of a character sequence.
70 * @returns the number of characters between @p *__p and the first
71 * default-initialized value of type @p char_type. In other words, uses
72 * the C-string algorithm for determining the length of a sequence of
76 length(const char_type
* __p
)
77 { return string_type::traits_type::length(__p
); }
80 * @brief Performs the identity translation.
82 * @param __c A character to the locale-specific character set.
87 translate(char_type __c
) const
91 * @brief Translates a character into a case-insensitive equivalent.
93 * @param __c A character to the locale-specific character set.
95 * @returns the locale-specific lower-case equivalent of __c.
96 * @throws std::bad_cast if the imbued locale does not support the ctype
100 translate_nocase(char_type __c
) const
102 typedef std::ctype
<char_type
> __ctype_type
;
103 const __ctype_type
& __fctyp(use_facet
<__ctype_type
>(_M_locale
));
104 return __fctyp
.tolower(__c
);
108 * @brief Gets a sort key for a character sequence.
110 * @param __first beginning of the character sequence.
111 * @param __last one-past-the-end of the character sequence.
113 * Returns a sort key for the character sequence designated by the
114 * iterator range [F1, F2) such that if the character sequence [G1, G2)
115 * sorts before the character sequence [H1, H2) then
116 * v.transform(G1, G2) < v.transform(H1, H2).
118 * What this really does is provide a more efficient way to compare a
119 * string to multiple other strings in locales with fancy collation
120 * rules and equivalence classes.
122 * @returns a locale-specific sort key equivalent to the input range.
124 * @throws std::bad_cast if the current locale does not have a collate
127 template<typename _Fwd_iter
>
129 transform(_Fwd_iter __first
, _Fwd_iter __last
) const
131 typedef std::collate
<char_type
> __collate_type
;
132 const __collate_type
& __fclt(use_facet
<__collate_type
>(_M_locale
));
133 string_type
__s(__first
, __last
);
134 return __fclt
.transform(__s
.data(), __s
.data() + __s
.size());
138 * @brief Gets a sort key for a character sequence, independent of case.
140 * @param __first beginning of the character sequence.
141 * @param __last one-past-the-end of the character sequence.
143 * Effects: if typeid(use_facet<collate<_Ch_type> >) ==
144 * typeid(collate_byname<_Ch_type>) and the form of the sort key
145 * returned by collate_byname<_Ch_type>::transform(__first, __last)
146 * is known and can be converted into a primary sort key
147 * then returns that key, otherwise returns an empty string.
149 * @todo Implement this function.
151 template<typename _Fwd_iter
>
153 transform_primary(_Fwd_iter __first
, _Fwd_iter __last
) const
154 { return string_type(); }
157 * @brief Gets a collation element by name.
159 * @param __first beginning of the collation element name.
160 * @param __last one-past-the-end of the collation element name.
162 * @returns a sequence of one or more characters that represents the
163 * collating element consisting of the character sequence designated by
164 * the iterator range [__first, __last). Returns an empty string if the
165 * character sequence is not a valid collating element.
167 * @todo Implement this function.
169 template<typename _Fwd_iter
>
171 lookup_collatename(_Fwd_iter __first
, _Fwd_iter __last
) const
172 { return string_type(); }
175 * @brief Maps one or more characters to a named character
178 * @param __first beginning of the character sequence.
179 * @param __last one-past-the-end of the character sequence.
180 * @param __icase ignores the case of the classification name.
182 * @returns an unspecified value that represents the character
183 * classification named by the character sequence designated by
184 * the iterator range [__first, __last). If @p icase is true,
185 * the returned mask identifies the classification regardless of
186 * the case of the characters to be matched (for example,
187 * [[:lower:]] is the same as [[:alpha:]]), otherwise a
188 * case-dependent classification is returned. The value
189 * returned shall be independent of the case of the characters
190 * in the character sequence. If the name is not recognized then
191 * returns a value that compares equal to 0.
193 * At least the following names (or their wide-character equivalent) are
211 * @todo Implement this function.
213 template<typename _Fwd_iter
>
215 lookup_classname(_Fwd_iter __first
, _Fwd_iter __last
,
216 bool __icase
= false) const
220 * @brief Determines if @p c is a member of an identified class.
222 * @param __c a character.
223 * @param __f a class type (as returned from lookup_classname).
225 * @returns true if the character @p __c is a member of the classification
226 * represented by @p __f, false otherwise.
228 * @throws std::bad_cast if the current locale does not have a ctype
232 isctype(_Ch_type __c
, char_class_type __f
) const;
235 * @brief Converts a digit to an int.
237 * @param __ch a character representing a digit.
238 * @param __radix the radix if the numeric conversion (limited to 8, 10,
241 * @returns the value represented by the digit __ch in base radix if the
242 * character __ch is a valid digit in base radix; otherwise returns -1.
245 value(_Ch_type __ch
, int __radix
) const;
248 * @brief Imbues the regex_traits object with a copy of a new locale.
250 * @param __loc A locale.
252 * @returns a copy of the previous locale in use by the regex_traits
255 * @note Calling imbue with a different locale than the one currently in
256 * use invalidates all cached data held by *this.
259 imbue(locale_type __loc
)
261 std::swap(_M_locale
, __loc
);
266 * @brief Gets a copy of the current locale in use by the regex_traits
271 { return _M_locale
; }
274 locale_type _M_locale
;
277 template<typename _Ch_type
>
279 regex_traits
<_Ch_type
>::
280 isctype(_Ch_type __c
, char_class_type __f
) const
282 typedef std::ctype
<char_type
> __ctype_type
;
283 const __ctype_type
& __fctyp(use_facet
<__ctype_type
>(_M_locale
));
285 if (__fctyp
.is(__f
, __c
))
288 // special case of underscore in [[:w:]]
289 if (__c
== __fctyp
.widen('_'))
291 const char __wb
[] = "w";
292 char_class_type __wt
= this->lookup_classname(__wb
,
293 __wb
+ sizeof(__wb
));
298 // special case of [[:space:]] in [[:blank:]]
299 if (__fctyp
.is(std::ctype_base::space
, __c
))
301 const char __bb
[] = "blank";
302 char_class_type __bt
= this->lookup_classname(__bb
,
303 __bb
+ sizeof(__bb
));
311 template<typename _Ch_type
>
313 regex_traits
<_Ch_type
>::
314 value(_Ch_type __ch
, int __radix
) const
316 std::basic_istringstream
<char_type
> __is(string_type(1, __ch
));
320 else if (__radix
== 16)
323 return __is
.fail() ? -1 : __v
;
326 // [7.8] Class basic_regex
328 * Objects of specializations of this class represent regular expressions
329 * constructed from sequences of character type @p _Ch_type.
331 * Storage for the regular expression is allocated and deallocated as
332 * necessary by the member functions of this class.
334 template<typename _Ch_type
, typename _Rx_traits
= regex_traits
<_Ch_type
> >
339 typedef _Ch_type value_type
;
340 typedef _Rx_traits traits_type
;
341 typedef typename
traits_type::string_type string_type
;
342 typedef regex_constants::syntax_option_type flag_type
;
343 typedef typename
traits_type::locale_type locale_type
;
350 static constexpr flag_type icase
= regex_constants::icase
;
351 static constexpr flag_type nosubs
= regex_constants::nosubs
;
352 static constexpr flag_type optimize
= regex_constants::optimize
;
353 static constexpr flag_type collate
= regex_constants::collate
;
354 static constexpr flag_type ECMAScript
= regex_constants::ECMAScript
;
355 static constexpr flag_type basic
= regex_constants::basic
;
356 static constexpr flag_type extended
= regex_constants::extended
;
357 static constexpr flag_type awk
= regex_constants::awk
;
358 static constexpr flag_type grep
= regex_constants::grep
;
359 static constexpr flag_type egrep
= regex_constants::egrep
;
362 // [7.8.2] construct/copy/destroy
364 * Constructs a basic regular expression that does not match any
365 * character sequence.
368 : _M_flags(ECMAScript
),
369 _M_automaton(__detail::__compile
<const _Ch_type
*, _Rx_traits
>(0, 0,
370 _M_traits
, _M_flags
))
374 * @brief Constructs a basic regular expression from the
375 * sequence [__p, __p + char_traits<_Ch_type>::length(__p))
376 * interpreted according to the flags in @p __f.
378 * @param __p A pointer to the start of a C-style null-terminated string
379 * containing a regular expression.
380 * @param __f Flags indicating the syntax rules and options.
382 * @throws regex_error if @p __p is not a valid regular expression.
385 basic_regex(const _Ch_type
* __p
, flag_type __f
= ECMAScript
)
387 _M_automaton(__detail::__compile(__p
, __p
+ _Rx_traits::length(__p
),
388 _M_traits
, _M_flags
))
392 * @brief Constructs a basic regular expression from the sequence
393 * [p, p + len) interpreted according to the flags in @p f.
395 * @param __p A pointer to the start of a string containing a regular
397 * @param __len The length of the string containing the regular
399 * @param __f Flags indicating the syntax rules and options.
401 * @throws regex_error if @p __p is not a valid regular expression.
403 basic_regex(const _Ch_type
* __p
, std::size_t __len
, flag_type __f
)
405 _M_automaton(__detail::__compile(__p
, __p
+ __len
, _M_traits
, _M_flags
))
409 * @brief Copy-constructs a basic regular expression.
411 * @param __rhs A @p regex object.
413 basic_regex(const basic_regex
& __rhs
)
414 : _M_flags(__rhs
._M_flags
), _M_traits(__rhs
._M_traits
),
415 _M_automaton(__rhs
._M_automaton
)
419 * @brief Move-constructs a basic regular expression.
421 * @param __rhs A @p regex object.
423 basic_regex(const basic_regex
&& __rhs
) noexcept
424 : _M_flags(__rhs
._M_flags
), _M_traits(__rhs
._M_traits
),
425 _M_automaton(std::move(__rhs
._M_automaton
))
429 * @brief Constructs a basic regular expression from the string
430 * @p s interpreted according to the flags in @p f.
432 * @param __s A string containing a regular expression.
433 * @param __f Flags indicating the syntax rules and options.
435 * @throws regex_error if @p __s is not a valid regular expression.
437 template<typename _Ch_traits
, typename _Ch_alloc
>
439 basic_regex(const std::basic_string
<_Ch_type
, _Ch_traits
,
441 flag_type __f
= ECMAScript
)
443 _M_automaton(__detail::__compile(__s
.begin(), __s
.end(),
444 _M_traits
, _M_flags
))
448 * @brief Constructs a basic regular expression from the range
449 * [first, last) interpreted according to the flags in @p f.
451 * @param __first The start of a range containing a valid regular
453 * @param __last The end of a range containing a valid regular
455 * @param __f The format flags of the regular expression.
457 * @throws regex_error if @p [__first, __last) is not a valid regular
460 template<typename _InputIterator
>
461 basic_regex(_InputIterator __first
, _InputIterator __last
,
462 flag_type __f
= ECMAScript
)
464 _M_automaton(__detail::__compile(__first
, __last
, _M_traits
, _M_flags
))
468 * @brief Constructs a basic regular expression from an initializer list.
470 * @param __l The initializer list.
471 * @param __f The format flags of the regular expression.
473 * @throws regex_error if @p __l is not a valid regular expression.
475 basic_regex(initializer_list
<_Ch_type
> __l
,
476 flag_type __f
= ECMAScript
)
478 _M_automaton(__detail::__compile(__l
.begin(), __l
.end(),
479 _M_traits
, _M_flags
))
483 * @brief Destroys a basic regular expression.
489 * @brief Assigns one regular expression to another.
492 operator=(const basic_regex
& __rhs
)
493 { return this->assign(__rhs
); }
496 * @brief Move-assigns one regular expression to another.
499 operator=(basic_regex
&& __rhs
) noexcept
500 { return this->assign(std::move(__rhs
)); }
503 * @brief Replaces a regular expression with a new one constructed from
504 * a C-style null-terminated string.
506 * @param __p A pointer to the start of a null-terminated C-style string
507 * containing a regular expression.
510 operator=(const _Ch_type
* __p
)
511 { return this->assign(__p
, flags()); }
514 * @brief Replaces a regular expression with a new one constructed from
517 * @param __s A pointer to a string containing a regular expression.
519 template<typename _Ch_typeraits
, typename _Alloc
>
521 operator=(const basic_string
<_Ch_type
, _Ch_typeraits
, _Alloc
>& __s
)
522 { return this->assign(__s
, flags()); }
526 * @brief the real assignment operator.
528 * @param __rhs Another regular expression object.
531 assign(const basic_regex
& __rhs
)
533 basic_regex
__tmp(__rhs
);
539 * @brief The move-assignment operator.
541 * @param __rhs Another regular expression object.
544 assign(basic_regex
&& __rhs
) noexcept
546 basic_regex
__tmp(std::move(__rhs
));
552 * @brief Assigns a new regular expression to a regex object from a
553 * C-style null-terminated string containing a regular expression
556 * @param __p A pointer to a C-style null-terminated string containing
557 * a regular expression pattern.
558 * @param __flags Syntax option flags.
560 * @throws regex_error if __p does not contain a valid regular
561 * expression pattern interpreted according to @p __flags. If
562 * regex_error is thrown, *this remains unchanged.
565 assign(const _Ch_type
* __p
, flag_type __flags
= ECMAScript
)
566 { return this->assign(string_type(__p
), __flags
); }
569 * @brief Assigns a new regular expression to a regex object from a
570 * C-style string containing a regular expression pattern.
572 * @param __p A pointer to a C-style string containing a
573 * regular expression pattern.
574 * @param __len The length of the regular expression pattern string.
575 * @param __flags Syntax option flags.
577 * @throws regex_error if p does not contain a valid regular
578 * expression pattern interpreted according to @p __flags. If
579 * regex_error is thrown, *this remains unchanged.
582 assign(const _Ch_type
* __p
, std::size_t __len
, flag_type __flags
)
583 { return this->assign(string_type(__p
, __len
), __flags
); }
586 * @brief Assigns a new regular expression to a regex object from a
587 * string containing a regular expression pattern.
589 * @param __s A string containing a regular expression pattern.
590 * @param __flags Syntax option flags.
592 * @throws regex_error if __s does not contain a valid regular
593 * expression pattern interpreted according to @p __flags. If
594 * regex_error is thrown, *this remains unchanged.
596 template<typename _Ch_typeraits
, typename _Alloc
>
598 assign(const basic_string
<_Ch_type
, _Ch_typeraits
, _Alloc
>& __s
,
599 flag_type __flags
= ECMAScript
)
601 basic_regex
__tmp(__s
, __flags
);
607 * @brief Assigns a new regular expression to a regex object.
609 * @param __first The start of a range containing a valid regular
611 * @param __last The end of a range containing a valid regular
613 * @param __flags Syntax option flags.
615 * @throws regex_error if p does not contain a valid regular
616 * expression pattern interpreted according to @p __flags. If
617 * regex_error is thrown, the object remains unchanged.
619 template<typename _InputIterator
>
621 assign(_InputIterator __first
, _InputIterator __last
,
622 flag_type __flags
= ECMAScript
)
623 { return this->assign(string_type(__first
, __last
), __flags
); }
626 * @brief Assigns a new regular expression to a regex object.
628 * @param __l An initializer list representing a regular expression.
629 * @param __flags Syntax option flags.
631 * @throws regex_error if @p __l does not contain a valid
632 * regular expression pattern interpreted according to @p
633 * __flags. If regex_error is thrown, the object remains
637 assign(initializer_list
<_Ch_type
> __l
, flag_type __flags
= ECMAScript
)
638 { return this->assign(__l
.begin(), __l
.end(), __flags
); }
640 // [7.8.4] const operations
642 * @brief Gets the number of marked subexpressions within the regular
647 { return _M_automaton
->_M_sub_count() - 1; }
650 * @brief Gets the flags used to construct the regular expression
651 * or in the last call to assign().
659 * @brief Imbues the regular expression object with the given locale.
661 * @param __loc A locale.
664 imbue(locale_type __loc
)
665 { return _M_traits
.imbue(__loc
); }
668 * @brief Gets the locale currently imbued in the regular expression
673 { return _M_traits
.getloc(); }
677 * @brief Swaps the contents of two regular expression objects.
679 * @param __rhs Another regular expression object.
682 swap(basic_regex
& __rhs
)
684 std::swap(_M_flags
, __rhs
._M_flags
);
685 std::swap(_M_traits
, __rhs
._M_traits
);
686 std::swap(_M_automaton
, __rhs
._M_automaton
);
689 #ifdef _GLIBCXX_DEBUG
691 _M_dot(std::ostream
& __ostr
)
692 { _M_automaton
->_M_dot(__ostr
); }
695 const __detail::_AutomatonPtr
&
696 _M_get_automaton() const
697 { return _M_automaton
; }
701 _Rx_traits _M_traits
;
702 __detail::_AutomatonPtr _M_automaton
;
705 /** @brief Standard regular expressions. */
706 typedef basic_regex
<char> regex
;
708 #ifdef _GLIBCXX_USE_WCHAR_T
709 /** @brief Standard wide-character regular expressions. */
710 typedef basic_regex
<wchar_t> wregex
;
714 // [7.8.6] basic_regex swap
716 * @brief Swaps the contents of two regular expression objects.
717 * @param __lhs First regular expression.
718 * @param __rhs Second regular expression.
720 template<typename _Ch_type
, typename _Rx_traits
>
722 swap(basic_regex
<_Ch_type
, _Rx_traits
>& __lhs
,
723 basic_regex
<_Ch_type
, _Rx_traits
>& __rhs
)
724 { __lhs
.swap(__rhs
); }
727 // [7.9] Class template sub_match
729 * A sequence of characters matched by a particular marked sub-expression.
731 * An object of this class is essentially a pair of iterators marking a
732 * matched subexpression within a regular expression pattern match. Such
733 * objects can be converted to and compared with std::basic_string objects
734 * of a similar base character type as the pattern matched by the regular
737 * The iterators that make up the pair are the usual half-open interval
738 * referencing the actual original pattern matched.
740 template<typename _BiIter
>
741 class sub_match
: public std::pair
<_BiIter
, _BiIter
>
743 typedef iterator_traits
<_BiIter
> __iter_traits
;
746 typedef typename
__iter_traits::value_type value_type
;
747 typedef typename
__iter_traits::difference_type difference_type
;
748 typedef _BiIter iterator
;
749 typedef std::basic_string
<value_type
> string_type
;
753 constexpr sub_match() : matched() { }
756 * Gets the length of the matching sequence.
760 { return this->matched
? std::distance(this->first
, this->second
) : 0; }
763 * @brief Gets the matching sequence as a string.
765 * @returns the matching sequence as a string.
767 * This is the implicit conversion operator. It is identical to the
768 * str() member function except that it will want to pop up in
769 * unexpected places and cause a great deal of confusion and cursing
772 operator string_type() const
775 ? string_type(this->first
, this->second
)
780 * @brief Gets the matching sequence as a string.
782 * @returns the matching sequence as a string.
788 ? string_type(this->first
, this->second
)
793 * @brief Compares this and another matched sequence.
795 * @param __s Another matched sequence to compare to this one.
797 * @retval <0 this matched sequence will collate before @p __s.
798 * @retval =0 this matched sequence is equivalent to @p __s.
799 * @retval <0 this matched sequence will collate after @p __s.
802 compare(const sub_match
& __s
) const
803 { return this->str().compare(__s
.str()); }
806 * @brief Compares this sub_match to a string.
808 * @param __s A string to compare to this sub_match.
810 * @retval <0 this matched sequence will collate before @p __s.
811 * @retval =0 this matched sequence is equivalent to @p __s.
812 * @retval <0 this matched sequence will collate after @p __s.
815 compare(const string_type
& __s
) const
816 { return this->str().compare(__s
); }
819 * @brief Compares this sub_match to a C-style string.
821 * @param __s A C-style string to compare to this sub_match.
823 * @retval <0 this matched sequence will collate before @p __s.
824 * @retval =0 this matched sequence is equivalent to @p __s.
825 * @retval <0 this matched sequence will collate after @p __s.
828 compare(const value_type
* __s
) const
829 { return this->str().compare(__s
); }
833 /** @brief Standard regex submatch over a C-style null-terminated string. */
834 typedef sub_match
<const char*> csub_match
;
836 /** @brief Standard regex submatch over a standard string. */
837 typedef sub_match
<string::const_iterator
> ssub_match
;
839 #ifdef _GLIBCXX_USE_WCHAR_T
840 /** @brief Regex submatch over a C-style null-terminated wide string. */
841 typedef sub_match
<const wchar_t*> wcsub_match
;
843 /** @brief Regex submatch over a standard wide string. */
844 typedef sub_match
<wstring::const_iterator
> wssub_match
;
847 // [7.9.2] sub_match non-member operators
850 * @brief Tests the equivalence of two regular expression submatches.
851 * @param __lhs First regular expression submatch.
852 * @param __rhs Second regular expression submatch.
853 * @returns true if @a __lhs is equivalent to @a __rhs, false otherwise.
855 template<typename _BiIter
>
857 operator==(const sub_match
<_BiIter
>& __lhs
, const sub_match
<_BiIter
>& __rhs
)
858 { return __lhs
.compare(__rhs
) == 0; }
861 * @brief Tests the inequivalence of two regular expression submatches.
862 * @param __lhs First regular expression submatch.
863 * @param __rhs Second regular expression submatch.
864 * @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise.
866 template<typename _BiIter
>
868 operator!=(const sub_match
<_BiIter
>& __lhs
, const sub_match
<_BiIter
>& __rhs
)
869 { return __lhs
.compare(__rhs
) != 0; }
872 * @brief Tests the ordering of two regular expression submatches.
873 * @param __lhs First regular expression submatch.
874 * @param __rhs Second regular expression submatch.
875 * @returns true if @a __lhs precedes @a __rhs, false otherwise.
877 template<typename _BiIter
>
879 operator<(const sub_match
<_BiIter
>& __lhs
, const sub_match
<_BiIter
>& __rhs
)
880 { return __lhs
.compare(__rhs
) < 0; }
883 * @brief Tests the ordering of two regular expression submatches.
884 * @param __lhs First regular expression submatch.
885 * @param __rhs Second regular expression submatch.
886 * @returns true if @a __lhs does not succeed @a __rhs, false otherwise.
888 template<typename _BiIter
>
890 operator<=(const sub_match
<_BiIter
>& __lhs
, const sub_match
<_BiIter
>& __rhs
)
891 { return __lhs
.compare(__rhs
) <= 0; }
894 * @brief Tests the ordering of two regular expression submatches.
895 * @param __lhs First regular expression submatch.
896 * @param __rhs Second regular expression submatch.
897 * @returns true if @a __lhs does not precede @a __rhs, false otherwise.
899 template<typename _BiIter
>
901 operator>=(const sub_match
<_BiIter
>& __lhs
, const sub_match
<_BiIter
>& __rhs
)
902 { return __lhs
.compare(__rhs
) >= 0; }
905 * @brief Tests the ordering of two regular expression submatches.
906 * @param __lhs First regular expression submatch.
907 * @param __rhs Second regular expression submatch.
908 * @returns true if @a __lhs succeeds @a __rhs, false otherwise.
910 template<typename _BiIter
>
912 operator>(const sub_match
<_BiIter
>& __lhs
, const sub_match
<_BiIter
>& __rhs
)
913 { return __lhs
.compare(__rhs
) > 0; }
915 // Alias for sub_match'd string.
916 template<typename _Bi_iter
, typename _Ch_traits
, typename _Ch_alloc
>
917 using __sub_match_string
= basic_string
<
918 typename iterator_traits
<_Bi_iter
>::value_type
,
919 _Ch_traits
, _Ch_alloc
>;
922 * @brief Tests the equivalence of a string and a regular expression
924 * @param __lhs A string.
925 * @param __rhs A regular expression submatch.
926 * @returns true if @a __lhs is equivalent to @a __rhs, false otherwise.
928 template<typename _Bi_iter
, typename _Ch_traits
, typename _Ch_alloc
>
930 operator==(const __sub_match_string
<_Bi_iter
, _Ch_traits
, _Ch_alloc
>& __lhs
,
931 const sub_match
<_Bi_iter
>& __rhs
)
932 { return __rhs
.compare(__lhs
.c_str()) == 0; }
935 * @brief Tests the inequivalence of a string and a regular expression
937 * @param __lhs A string.
938 * @param __rhs A regular expression submatch.
939 * @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise.
941 template<typename _Bi_iter
, typename _Ch_traits
, typename _Ch_alloc
>
943 operator!=(const __sub_match_string
<_Bi_iter
, _Ch_traits
, _Ch_alloc
>& __lhs
,
944 const sub_match
<_Bi_iter
>& __rhs
)
945 { return !(__lhs
== __rhs
); }
948 * @brief Tests the ordering of a string and a regular expression submatch.
949 * @param __lhs A string.
950 * @param __rhs A regular expression submatch.
951 * @returns true if @a __lhs precedes @a __rhs, false otherwise.
953 template<typename _Bi_iter
, typename _Ch_traits
, typename _Ch_alloc
>
955 operator<(const __sub_match_string
<_Bi_iter
, _Ch_traits
, _Ch_alloc
>& __lhs
,
956 const sub_match
<_Bi_iter
>& __rhs
)
957 { return __rhs
.compare(__lhs
.c_str()) > 0; }
960 * @brief Tests the ordering of a string and a regular expression submatch.
961 * @param __lhs A string.
962 * @param __rhs A regular expression submatch.
963 * @returns true if @a __lhs succeeds @a __rhs, false otherwise.
965 template<typename _Bi_iter
, typename _Ch_traits
, typename _Ch_alloc
>
967 operator>(const __sub_match_string
<_Bi_iter
, _Ch_traits
, _Ch_alloc
>& __lhs
,
968 const sub_match
<_Bi_iter
>& __rhs
)
969 { return __rhs
< __lhs
; }
972 * @brief Tests the ordering of a string and a regular expression submatch.
973 * @param __lhs A string.
974 * @param __rhs A regular expression submatch.
975 * @returns true if @a __lhs does not precede @a __rhs, false otherwise.
977 template<typename _Bi_iter
, typename _Ch_traits
, typename _Ch_alloc
>
979 operator>=(const __sub_match_string
<_Bi_iter
, _Ch_traits
, _Ch_alloc
>& __lhs
,
980 const sub_match
<_Bi_iter
>& __rhs
)
981 { return !(__lhs
< __rhs
); }
984 * @brief Tests the ordering of a string and a regular expression submatch.
985 * @param __lhs A string.
986 * @param __rhs A regular expression submatch.
987 * @returns true if @a __lhs does not succeed @a __rhs, false otherwise.
989 template<typename _Bi_iter
, typename _Ch_traits
, typename _Ch_alloc
>
991 operator<=(const __sub_match_string
<_Bi_iter
, _Ch_traits
, _Ch_alloc
>& __lhs
,
992 const sub_match
<_Bi_iter
>& __rhs
)
993 { return !(__rhs
< __lhs
); }
996 * @brief Tests the equivalence of a regular expression submatch and a
998 * @param __lhs A regular expression submatch.
999 * @param __rhs A string.
1000 * @returns true if @a __lhs is equivalent to @a __rhs, false otherwise.
1002 template<typename _Bi_iter
, typename _Ch_traits
, typename _Ch_alloc
>
1004 operator==(const sub_match
<_Bi_iter
>& __lhs
,
1005 const __sub_match_string
<_Bi_iter
, _Ch_traits
, _Ch_alloc
>& __rhs
)
1006 { return __lhs
.compare(__rhs
.c_str()) == 0; }
1009 * @brief Tests the inequivalence of a regular expression submatch and a
1011 * @param __lhs A regular expression submatch.
1012 * @param __rhs A string.
1013 * @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise.
1015 template<typename _Bi_iter
, typename _Ch_traits
, typename _Ch_alloc
>
1017 operator!=(const sub_match
<_Bi_iter
>& __lhs
,
1018 const __sub_match_string
<_Bi_iter
, _Ch_traits
, _Ch_alloc
>& __rhs
)
1019 { return !(__lhs
== __rhs
); }
1022 * @brief Tests the ordering of a regular expression submatch and a string.
1023 * @param __lhs A regular expression submatch.
1024 * @param __rhs A string.
1025 * @returns true if @a __lhs precedes @a __rhs, false otherwise.
1027 template<typename _Bi_iter
, class _Ch_traits
, class _Ch_alloc
>
1029 operator<(const sub_match
<_Bi_iter
>& __lhs
,
1030 const __sub_match_string
<_Bi_iter
, _Ch_traits
, _Ch_alloc
>& __rhs
)
1031 { return __lhs
.compare(__rhs
.c_str()) < 0; }
1034 * @brief Tests the ordering of a regular expression submatch and a string.
1035 * @param __lhs A regular expression submatch.
1036 * @param __rhs A string.
1037 * @returns true if @a __lhs succeeds @a __rhs, false otherwise.
1039 template<typename _Bi_iter
, class _Ch_traits
, class _Ch_alloc
>
1041 operator>(const sub_match
<_Bi_iter
>& __lhs
,
1042 const __sub_match_string
<_Bi_iter
, _Ch_traits
, _Ch_alloc
>& __rhs
)
1043 { return __rhs
< __lhs
; }
1046 * @brief Tests the ordering of a regular expression submatch and a string.
1047 * @param __lhs A regular expression submatch.
1048 * @param __rhs A string.
1049 * @returns true if @a __lhs does not precede @a __rhs, false otherwise.
1051 template<typename _Bi_iter
, class _Ch_traits
, class _Ch_alloc
>
1053 operator>=(const sub_match
<_Bi_iter
>& __lhs
,
1054 const __sub_match_string
<_Bi_iter
, _Ch_traits
, _Ch_alloc
>& __rhs
)
1055 { return !(__lhs
< __rhs
); }
1058 * @brief Tests the ordering of a regular expression submatch and a string.
1059 * @param __lhs A regular expression submatch.
1060 * @param __rhs A string.
1061 * @returns true if @a __lhs does not succeed @a __rhs, false otherwise.
1063 template<typename _Bi_iter
, class _Ch_traits
, class _Ch_alloc
>
1065 operator<=(const sub_match
<_Bi_iter
>& __lhs
,
1066 const __sub_match_string
<_Bi_iter
, _Ch_traits
, _Ch_alloc
>& __rhs
)
1067 { return !(__rhs
< __lhs
); }
1070 * @brief Tests the equivalence of a C string and a regular expression
1072 * @param __lhs A C string.
1073 * @param __rhs A regular expression submatch.
1074 * @returns true if @a __lhs is equivalent to @a __rhs, false otherwise.
1076 template<typename _Bi_iter
>
1078 operator==(typename iterator_traits
<_Bi_iter
>::value_type
const* __lhs
,
1079 const sub_match
<_Bi_iter
>& __rhs
)
1080 { return __rhs
.compare(__lhs
) == 0; }
1083 * @brief Tests the inequivalence of an iterator value and a regular
1084 * expression submatch.
1085 * @param __lhs A regular expression submatch.
1086 * @param __rhs A string.
1087 * @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise.
1089 template<typename _Bi_iter
>
1091 operator!=(typename iterator_traits
<_Bi_iter
>::value_type
const* __lhs
,
1092 const sub_match
<_Bi_iter
>& __rhs
)
1093 { return !(__lhs
== __rhs
); }
1096 * @brief Tests the ordering of a string and a regular expression submatch.
1097 * @param __lhs A string.
1098 * @param __rhs A regular expression submatch.
1099 * @returns true if @a __lhs precedes @a __rhs, false otherwise.
1101 template<typename _Bi_iter
>
1103 operator<(typename iterator_traits
<_Bi_iter
>::value_type
const* __lhs
,
1104 const sub_match
<_Bi_iter
>& __rhs
)
1105 { return __rhs
.compare(__lhs
) > 0; }
1108 * @brief Tests the ordering of a string and a regular expression submatch.
1109 * @param __lhs A string.
1110 * @param __rhs A regular expression submatch.
1111 * @returns true if @a __lhs succeeds @a __rhs, false otherwise.
1113 template<typename _Bi_iter
>
1115 operator>(typename iterator_traits
<_Bi_iter
>::value_type
const* __lhs
,
1116 const sub_match
<_Bi_iter
>& __rhs
)
1117 { return __rhs
< __lhs
; }
1120 * @brief Tests the ordering of a string and a regular expression submatch.
1121 * @param __lhs A string.
1122 * @param __rhs A regular expression submatch.
1123 * @returns true if @a __lhs does not precede @a __rhs, false otherwise.
1125 template<typename _Bi_iter
>
1127 operator>=(typename iterator_traits
<_Bi_iter
>::value_type
const* __lhs
,
1128 const sub_match
<_Bi_iter
>& __rhs
)
1129 { return !(__lhs
< __rhs
); }
1132 * @brief Tests the ordering of a string and a regular expression submatch.
1133 * @param __lhs A string.
1134 * @param __rhs A regular expression submatch.
1135 * @returns true if @a __lhs does not succeed @a __rhs, false otherwise.
1137 template<typename _Bi_iter
>
1139 operator<=(typename iterator_traits
<_Bi_iter
>::value_type
const* __lhs
,
1140 const sub_match
<_Bi_iter
>& __rhs
)
1141 { return !(__rhs
< __lhs
); }
1144 * @brief Tests the equivalence of a regular expression submatch and a
1146 * @param __lhs A regular expression submatch.
1147 * @param __rhs A pointer to a string?
1148 * @returns true if @a __lhs is equivalent to @a __rhs, false otherwise.
1150 template<typename _Bi_iter
>
1152 operator==(const sub_match
<_Bi_iter
>& __lhs
,
1153 typename iterator_traits
<_Bi_iter
>::value_type
const* __rhs
)
1154 { return __lhs
.compare(__rhs
) == 0; }
1157 * @brief Tests the inequivalence of a regular expression submatch and a
1159 * @param __lhs A regular expression submatch.
1160 * @param __rhs A pointer to a string.
1161 * @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise.
1163 template<typename _Bi_iter
>
1165 operator!=(const sub_match
<_Bi_iter
>& __lhs
,
1166 typename iterator_traits
<_Bi_iter
>::value_type
const* __rhs
)
1167 { return !(__lhs
== __rhs
); }
1170 * @brief Tests the ordering of a regular expression submatch and a string.
1171 * @param __lhs A regular expression submatch.
1172 * @param __rhs A string.
1173 * @returns true if @a __lhs precedes @a __rhs, false otherwise.
1175 template<typename _Bi_iter
>
1177 operator<(const sub_match
<_Bi_iter
>& __lhs
,
1178 typename iterator_traits
<_Bi_iter
>::value_type
const* __rhs
)
1179 { return __lhs
.compare(__rhs
) < 0; }
1182 * @brief Tests the ordering of a regular expression submatch and a string.
1183 * @param __lhs A regular expression submatch.
1184 * @param __rhs A string.
1185 * @returns true if @a __lhs succeeds @a __rhs, false otherwise.
1187 template<typename _Bi_iter
>
1189 operator>(const sub_match
<_Bi_iter
>& __lhs
,
1190 typename iterator_traits
<_Bi_iter
>::value_type
const* __rhs
)
1191 { return __rhs
< __lhs
; }
1194 * @brief Tests the ordering of a regular expression submatch and a string.
1195 * @param __lhs A regular expression submatch.
1196 * @param __rhs A string.
1197 * @returns true if @a __lhs does not precede @a __rhs, false otherwise.
1199 template<typename _Bi_iter
>
1201 operator>=(const sub_match
<_Bi_iter
>& __lhs
,
1202 typename iterator_traits
<_Bi_iter
>::value_type
const* __rhs
)
1203 { return !(__lhs
< __rhs
); }
1206 * @brief Tests the ordering of a regular expression submatch and a string.
1207 * @param __lhs A regular expression submatch.
1208 * @param __rhs A string.
1209 * @returns true if @a __lhs does not succeed @a __rhs, false otherwise.
1211 template<typename _Bi_iter
>
1213 operator<=(const sub_match
<_Bi_iter
>& __lhs
,
1214 typename iterator_traits
<_Bi_iter
>::value_type
const* __rhs
)
1215 { return !(__rhs
< __lhs
); }
1218 * @brief Tests the equivalence of a string and a regular expression
1220 * @param __lhs A string.
1221 * @param __rhs A regular expression submatch.
1222 * @returns true if @a __lhs is equivalent to @a __rhs, false otherwise.
1224 template<typename _Bi_iter
>
1226 operator==(typename iterator_traits
<_Bi_iter
>::value_type
const& __lhs
,
1227 const sub_match
<_Bi_iter
>& __rhs
)
1229 typedef typename sub_match
<_Bi_iter
>::string_type string_type
;
1230 return __rhs
.compare(string_type(1, __lhs
)) == 0;
1234 * @brief Tests the inequivalence of a string and a regular expression
1236 * @param __lhs A string.
1237 * @param __rhs A regular expression submatch.
1238 * @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise.
1240 template<typename _Bi_iter
>
1242 operator!=(typename iterator_traits
<_Bi_iter
>::value_type
const& __lhs
,
1243 const sub_match
<_Bi_iter
>& __rhs
)
1244 { return !(__lhs
== __rhs
); }
1247 * @brief Tests the ordering of a string and a regular expression submatch.
1248 * @param __lhs A string.
1249 * @param __rhs A regular expression submatch.
1250 * @returns true if @a __lhs precedes @a __rhs, false otherwise.
1252 template<typename _Bi_iter
>
1254 operator<(typename iterator_traits
<_Bi_iter
>::value_type
const& __lhs
,
1255 const sub_match
<_Bi_iter
>& __rhs
)
1257 typedef typename sub_match
<_Bi_iter
>::string_type string_type
;
1258 return __rhs
.compare(string_type(1, __lhs
)) > 0;
1262 * @brief Tests the ordering of a string and a regular expression submatch.
1263 * @param __lhs A string.
1264 * @param __rhs A regular expression submatch.
1265 * @returns true if @a __lhs succeeds @a __rhs, false otherwise.
1267 template<typename _Bi_iter
>
1269 operator>(typename iterator_traits
<_Bi_iter
>::value_type
const& __lhs
,
1270 const sub_match
<_Bi_iter
>& __rhs
)
1271 { return __rhs
< __lhs
; }
1274 * @brief Tests the ordering of a string and a regular expression submatch.
1275 * @param __lhs A string.
1276 * @param __rhs A regular expression submatch.
1277 * @returns true if @a __lhs does not precede @a __rhs, false otherwise.
1279 template<typename _Bi_iter
>
1281 operator>=(typename iterator_traits
<_Bi_iter
>::value_type
const& __lhs
,
1282 const sub_match
<_Bi_iter
>& __rhs
)
1283 { return !(__lhs
< __rhs
); }
1286 * @brief Tests the ordering of a string and a regular expression submatch.
1287 * @param __lhs A string.
1288 * @param __rhs A regular expression submatch.
1289 * @returns true if @a __lhs does not succeed @a __rhs, false otherwise.
1291 template<typename _Bi_iter
>
1293 operator<=(typename iterator_traits
<_Bi_iter
>::value_type
const& __lhs
,
1294 const sub_match
<_Bi_iter
>& __rhs
)
1295 { return !(__rhs
< __lhs
); }
1298 * @brief Tests the equivalence of a regular expression submatch and a
1300 * @param __lhs A regular expression submatch.
1301 * @param __rhs A const string reference.
1302 * @returns true if @a __lhs is equivalent to @a __rhs, false otherwise.
1304 template<typename _Bi_iter
>
1306 operator==(const sub_match
<_Bi_iter
>& __lhs
,
1307 typename iterator_traits
<_Bi_iter
>::value_type
const& __rhs
)
1309 typedef typename sub_match
<_Bi_iter
>::string_type string_type
;
1310 return __lhs
.compare(string_type(1, __rhs
)) == 0;
1314 * @brief Tests the inequivalence of a regular expression submatch and a
1316 * @param __lhs A regular expression submatch.
1317 * @param __rhs A const string reference.
1318 * @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise.
1320 template<typename _Bi_iter
>
1322 operator!=(const sub_match
<_Bi_iter
>& __lhs
,
1323 typename iterator_traits
<_Bi_iter
>::value_type
const& __rhs
)
1324 { return !(__lhs
== __rhs
); }
1327 * @brief Tests the ordering of a regular expression submatch and a string.
1328 * @param __lhs A regular expression submatch.
1329 * @param __rhs A const string reference.
1330 * @returns true if @a __lhs precedes @a __rhs, false otherwise.
1332 template<typename _Bi_iter
>
1334 operator<(const sub_match
<_Bi_iter
>& __lhs
,
1335 typename iterator_traits
<_Bi_iter
>::value_type
const& __rhs
)
1337 typedef typename sub_match
<_Bi_iter
>::string_type string_type
;
1338 return __lhs
.compare(string_type(1, __rhs
)) < 0;
1342 * @brief Tests the ordering of a regular expression submatch and a string.
1343 * @param __lhs A regular expression submatch.
1344 * @param __rhs A const string reference.
1345 * @returns true if @a __lhs succeeds @a __rhs, false otherwise.
1347 template<typename _Bi_iter
>
1349 operator>(const sub_match
<_Bi_iter
>& __lhs
,
1350 typename iterator_traits
<_Bi_iter
>::value_type
const& __rhs
)
1351 { return __rhs
< __lhs
; }
1354 * @brief Tests the ordering of a regular expression submatch and a string.
1355 * @param __lhs A regular expression submatch.
1356 * @param __rhs A const string reference.
1357 * @returns true if @a __lhs does not precede @a __rhs, false otherwise.
1359 template<typename _Bi_iter
>
1361 operator>=(const sub_match
<_Bi_iter
>& __lhs
,
1362 typename iterator_traits
<_Bi_iter
>::value_type
const& __rhs
)
1363 { return !(__lhs
< __rhs
); }
1366 * @brief Tests the ordering of a regular expression submatch and a string.
1367 * @param __lhs A regular expression submatch.
1368 * @param __rhs A const string reference.
1369 * @returns true if @a __lhs does not succeed @a __rhs, false otherwise.
1371 template<typename _Bi_iter
>
1373 operator<=(const sub_match
<_Bi_iter
>& __lhs
,
1374 typename iterator_traits
<_Bi_iter
>::value_type
const& __rhs
)
1375 { return !(__rhs
< __lhs
); }
1378 * @brief Inserts a matched string into an output stream.
1380 * @param __os The output stream.
1381 * @param __m A submatch string.
1383 * @returns the output stream with the submatch string inserted.
1385 template<typename _Ch_type
, typename _Ch_traits
, typename _Bi_iter
>
1387 basic_ostream
<_Ch_type
, _Ch_traits
>&
1388 operator<<(basic_ostream
<_Ch_type
, _Ch_traits
>& __os
,
1389 const sub_match
<_Bi_iter
>& __m
)
1390 { return __os
<< __m
.str(); }
1392 // [7.10] Class template match_results
1395 * Special sub_match object representing an unmatched sub-expression.
1397 template<typename _Bi_iter
>
1398 inline const sub_match
<_Bi_iter
>&
1401 static const sub_match
<_Bi_iter
> __unmatched
= sub_match
<_Bi_iter
>();
1406 * @brief The results of a match or search operation.
1408 * A collection of character sequences representing the result of a regular
1409 * expression match. Storage for the collection is allocated and freed as
1410 * necessary by the member functions of class template match_results.
1412 * This class satisfies the Sequence requirements, with the exception that
1413 * only the operations defined for a const-qualified Sequence are supported.
1415 * The sub_match object stored at index 0 represents sub-expression 0, i.e.
1416 * the whole match. In this case the %sub_match member matched is always true.
1417 * The sub_match object stored at index n denotes what matched the marked
1418 * sub-expression n within the matched expression. If the sub-expression n
1419 * participated in a regular expression match then the %sub_match member
1420 * matched evaluates to true, and members first and second denote the range
1421 * of characters [first, second) which formed that match. Otherwise matched
1422 * is false, and members first and second point to the end of the sequence
1423 * that was searched.
1427 template<typename _Bi_iter
,
1428 typename _Alloc
= allocator
<sub_match
<_Bi_iter
> > >
1430 : private std::vector
<sub_match
<_Bi_iter
>, _Alloc
>
1434 * The vector base is empty if this does not represent a successful match.
1435 * Otherwise it contains n+3 elements where n is the number of marked
1438 * [1] 1st marked subexpression
1440 * [n] nth marked subexpression
1444 typedef std::vector
<sub_match
<_Bi_iter
>, _Alloc
> _Base_type
;
1445 typedef std::iterator_traits
<_Bi_iter
> __iter_traits
;
1446 typedef regex_constants::match_flag_type match_flag_type
;
1450 * @name 10.? Public Types
1453 typedef _Alloc allocator_type
;
1454 typedef sub_match
<_Bi_iter
> value_type
;
1455 typedef const value_type
& const_reference
;
1456 typedef const_reference reference
;
1457 typedef typename
_Base_type::const_iterator const_iterator
;
1458 typedef const_iterator iterator
;
1459 typedef typename
__iter_traits::difference_type difference_type
;
1460 typedef typename
__iter_traits::value_type char_type
;
1461 typedef typename allocator_traits
<_Alloc
>::size_type size_type
;
1464 typedef std::basic_string
<char_type
> string_type
;
1469 * @name 28.10.1 Construction, Copying, and Destruction
1474 * @brief Constructs a default %match_results container.
1475 * @post size() returns 0 and str() returns an empty string.
1478 match_results(const _Alloc
& __a
= _Alloc())
1483 * @brief Copy constructs a %match_results.
1485 match_results(const match_results
& __rhs
)
1490 * @brief Move constructs a %match_results.
1492 match_results(match_results
&& __rhs
) noexcept
1493 : _Base_type(std::move(__rhs
))
1497 * @brief Assigns rhs to *this.
1500 operator=(const match_results
& __rhs
)
1502 match_results(__rhs
).swap(*this);
1507 * @brief Move-assigns rhs to *this.
1510 operator=(match_results
&& __rhs
)
1512 match_results(std::move(__rhs
)).swap(*this);
1517 * @brief Destroys a %match_results object.
1526 * @brief Indicates if the %match_results is ready.
1527 * @retval true The object has a fully-established result state.
1528 * @retval false The object is not ready.
1530 bool ready() const { return !_Base_type::empty(); }
1533 * @name 28.10.2 Size
1538 * @brief Gets the number of matches and submatches.
1540 * The number of matches for a given regular expression will be either 0
1541 * if there was no match or mark_count() + 1 if a match was successful.
1542 * Some matches may be empty.
1544 * @returns the number of matches found.
1549 size_type __size
= _Base_type::size();
1550 return (__size
&& _Base_type::operator[](0).matched
) ? __size
- 2 : 0;
1555 { return _Base_type::max_size(); }
1558 * @brief Indicates if the %match_results contains no results.
1559 * @retval true The %match_results object is empty.
1560 * @retval false The %match_results object is not empty.
1564 { return size() == 0; }
1569 * @name 10.3 Element Access
1574 * @brief Gets the length of the indicated submatch.
1575 * @param __sub indicates the submatch.
1576 * @pre ready() == true
1578 * This function returns the length of the indicated submatch, or the
1579 * length of the entire match if @p __sub is zero (the default).
1582 length(size_type __sub
= 0) const
1583 { return (*this)[__sub
].length(); }
1586 * @brief Gets the offset of the beginning of the indicated submatch.
1587 * @param __sub indicates the submatch.
1588 * @pre ready() == true
1590 * This function returns the offset from the beginning of the target
1591 * sequence to the beginning of the submatch, unless the value of @p __sub
1592 * is zero (the default), in which case this function returns the offset
1593 * from the beginning of the target sequence to the beginning of the
1596 * Returns -1 if @p __sub is out of range.
1599 position(size_type __sub
= 0) const
1601 return __sub
< size() ? std::distance(this->prefix().first
,
1602 (*this)[__sub
].first
) : -1;
1606 * @brief Gets the match or submatch converted to a string type.
1607 * @param __sub indicates the submatch.
1608 * @pre ready() == true
1610 * This function gets the submatch (or match, if @p __sub is
1611 * zero) extracted from the target range and converted to the
1612 * associated string type.
1615 str(size_type __sub
= 0) const
1616 { return (*this)[__sub
].str(); }
1619 * @brief Gets a %sub_match reference for the match or submatch.
1620 * @param __sub indicates the submatch.
1621 * @pre ready() == true
1623 * This function gets a reference to the indicated submatch, or
1624 * the entire match if @p __sub is zero.
1626 * If @p __sub >= size() then this function returns a %sub_match with a
1627 * special value indicating no submatch.
1630 operator[](size_type __sub
) const
1632 _GLIBCXX_DEBUG_ASSERT( ready() );
1633 return __sub
< size()
1634 ? _Base_type::operator[](__sub
)
1635 : __unmatched_sub
<_Bi_iter
>();
1639 * @brief Gets a %sub_match representing the match prefix.
1640 * @pre ready() == true
1642 * This function gets a reference to a %sub_match object representing the
1643 * part of the target range between the start of the target range and the
1644 * start of the match.
1649 _GLIBCXX_DEBUG_ASSERT( ready() );
1651 ? _Base_type::operator[](_Base_type::size() - 2)
1652 : __unmatched_sub
<_Bi_iter
>();
1656 * @brief Gets a %sub_match representing the match suffix.
1657 * @pre ready() == true
1659 * This function gets a reference to a %sub_match object representing the
1660 * part of the target range between the end of the match and the end of
1666 _GLIBCXX_DEBUG_ASSERT( ready() );
1668 ? _Base_type::operator[](_Base_type::size() - 1)
1669 : __unmatched_sub
<_Bi_iter
>();
1673 * @brief Gets an iterator to the start of the %sub_match collection.
1677 { return _Base_type::begin(); }
1680 * @brief Gets an iterator to the start of the %sub_match collection.
1684 { return _Base_type::cbegin(); }
1687 * @brief Gets an iterator to one-past-the-end of the collection.
1691 { return !empty() ? _Base_type::end() - 2 : _Base_type::end(); }
1694 * @brief Gets an iterator to one-past-the-end of the collection.
1703 * @name 10.4 Formatting
1705 * These functions perform formatted substitution of the matched
1706 * character sequences into their target. The format specifiers and
1707 * escape sequences accepted by these functions are determined by
1708 * their @p flags parameter as documented above.
1713 * @pre ready() == true
1714 * @todo Implement this function.
1716 template<typename _Out_iter
>
1718 format(_Out_iter __out
, const char_type
* __fmt_first
,
1719 const char_type
* __fmt_last
,
1720 match_flag_type __flags
= regex_constants::format_default
) const
1724 * @pre ready() == true
1726 template<typename _Out_iter
, typename _St
, typename _Sa
>
1728 format(_Out_iter __out
, const basic_string
<char_type
, _St
, _Sa
>& __fmt
,
1729 match_flag_type __flags
= regex_constants::format_default
) const
1731 return format(__out
, __fmt
.data(), __fmt
.data() + __fmt
.size(),
1736 * @pre ready() == true
1738 template<typename _Out_iter
, typename _St
, typename _Sa
>
1739 basic_string
<char_type
, _St
, _Sa
>
1740 format(const basic_string
<char_type
, _St
, _Sa
>& __fmt
,
1741 match_flag_type __flags
= regex_constants::format_default
) const
1743 basic_string
<char_type
, _St
, _Sa
> __result
;
1744 format(std::back_inserter(__result
), __fmt
, __flags
);
1749 * @pre ready() == true
1752 format(const char_type
* __fmt
,
1753 match_flag_type __flags
= regex_constants::format_default
) const
1755 string_type __result
;
1756 format(std::back_inserter(__result
),
1757 __fmt
+ char_traits
<char_type
>::length(__fmt
),
1765 * @name 10.5 Allocator
1770 * @brief Gets a copy of the allocator.
1773 get_allocator() const
1774 { return _Base_type::get_allocator(); }
1784 * @brief Swaps the contents of two match_results.
1787 swap(match_results
& __that
)
1788 { _Base_type::swap(__that
); }
1792 friend class __detail::_SpecializedResults
<_Bi_iter
, _Alloc
>;
1795 typedef match_results
<const char*> cmatch
;
1796 typedef match_results
<string::const_iterator
> smatch
;
1797 #ifdef _GLIBCXX_USE_WCHAR_T
1798 typedef match_results
<const wchar_t*> wcmatch
;
1799 typedef match_results
<wstring::const_iterator
> wsmatch
;
1802 // match_results comparisons
1804 * @brief Compares two match_results for equality.
1805 * @returns true if the two objects refer to the same match,
1808 template<typename _Bi_iter
, typename _Alloc
>
1810 operator==(const match_results
<_Bi_iter
, _Alloc
>& __m1
,
1811 const match_results
<_Bi_iter
, _Alloc
>& __m2
)
1813 if (__m1
.ready() != __m2
.ready())
1815 if (!__m1
.ready()) // both are not ready
1817 if (__m1
.empty() != __m2
.empty())
1819 if (__m1
.empty()) // both are empty
1821 return __m1
.prefix() == __m2
.prefix()
1822 && __m1
.size() == __m2
.size()
1823 && std::equal(__m1
.begin(), __m1
.end(), __m2
.begin())
1824 && __m1
.suffix() == __m2
.suffix();
1828 * @brief Compares two match_results for inequality.
1829 * @returns true if the two objects do not refer to the same match,
1832 template<typename _Bi_iter
, class _Alloc
>
1834 operator!=(const match_results
<_Bi_iter
, _Alloc
>& __m1
,
1835 const match_results
<_Bi_iter
, _Alloc
>& __m2
)
1836 { return !(__m1
== __m2
); }
1838 // [7.10.6] match_results swap
1840 * @brief Swaps two match results.
1841 * @param __lhs A match result.
1842 * @param __rhs A match result.
1844 * The contents of the two match_results objects are swapped.
1846 template<typename _Bi_iter
, typename _Alloc
>
1848 swap(match_results
<_Bi_iter
, _Alloc
>& __lhs
,
1849 match_results
<_Bi_iter
, _Alloc
>& __rhs
)
1850 { __lhs
.swap(__rhs
); }
1852 // [7.11.2] Function template regex_match
1854 * @name Matching, Searching, and Replacing
1859 * @brief Determines if there is a match between the regular expression @p e
1860 * and all of the character sequence [first, last).
1862 * @param __s Start of the character sequence to match.
1863 * @param __e One-past-the-end of the character sequence to match.
1864 * @param __m The match results.
1865 * @param __re The regular expression.
1866 * @param __flags Controls how the regular expression is matched.
1868 * @retval true A match exists.
1869 * @retval false Otherwise.
1871 * @throws an exception of type regex_error.
1873 * @todo Implement this function.
1875 template<typename _Bi_iter
, typename _Alloc
,
1876 typename _Ch_type
, typename _Rx_traits
>
1878 regex_match(_Bi_iter __s
,
1880 match_results
<_Bi_iter
, _Alloc
>& __m
,
1881 const basic_regex
<_Ch_type
, _Rx_traits
>& __re
,
1882 regex_constants::match_flag_type __flags
1883 = regex_constants::match_default
)
1885 __detail::_AutomatonPtr __a
= __re
._M_get_automaton();
1886 __detail::_Automaton::_SizeT __sz
= __a
->_M_sub_count();
1887 __detail::_SpecializedCursor
<_Bi_iter
> __cs(__s
, __e
);
1888 __detail::_SpecializedResults
<_Bi_iter
, _Alloc
> __r(__sz
, __cs
, __m
);
1889 __detail::_Grep_matcher
__matcher(__cs
, __r
, __a
, __flags
);
1890 return __m
[0].matched
;
1894 * @brief Indicates if there is a match between the regular expression @p e
1895 * and all of the character sequence [first, last).
1897 * @param __first Beginning of the character sequence to match.
1898 * @param __last One-past-the-end of the character sequence to match.
1899 * @param __re The regular expression.
1900 * @param __flags Controls how the regular expression is matched.
1902 * @retval true A match exists.
1903 * @retval false Otherwise.
1905 * @throws an exception of type regex_error.
1907 template<typename _Bi_iter
, typename _Ch_type
, typename _Rx_traits
>
1909 regex_match(_Bi_iter __first
, _Bi_iter __last
,
1910 const basic_regex
<_Ch_type
, _Rx_traits
>& __re
,
1911 regex_constants::match_flag_type __flags
1912 = regex_constants::match_default
)
1914 match_results
<_Bi_iter
> __what
;
1915 return regex_match(__first
, __last
, __what
, __re
, __flags
);
1919 * @brief Determines if there is a match between the regular expression @p e
1920 * and a C-style null-terminated string.
1922 * @param __s The C-style null-terminated string to match.
1923 * @param __m The match results.
1924 * @param __re The regular expression.
1925 * @param __f Controls how the regular expression is matched.
1927 * @retval true A match exists.
1928 * @retval false Otherwise.
1930 * @throws an exception of type regex_error.
1932 template<typename _Ch_type
, typename _Alloc
, typename _Rx_traits
>
1934 regex_match(const _Ch_type
* __s
,
1935 match_results
<const _Ch_type
*, _Alloc
>& __m
,
1936 const basic_regex
<_Ch_type
, _Rx_traits
>& __re
,
1937 regex_constants::match_flag_type __f
1938 = regex_constants::match_default
)
1939 { return regex_match(__s
, __s
+ _Rx_traits::length(__s
), __m
, __re
, __f
); }
1942 * @brief Determines if there is a match between the regular expression @p e
1945 * @param __s The string to match.
1946 * @param __m The match results.
1947 * @param __re The regular expression.
1948 * @param __flags Controls how the regular expression is matched.
1950 * @retval true A match exists.
1951 * @retval false Otherwise.
1953 * @throws an exception of type regex_error.
1955 template<typename _Ch_traits
, typename _Ch_alloc
,
1956 typename _Alloc
, typename _Ch_type
, typename _Rx_traits
>
1958 regex_match(const basic_string
<_Ch_type
, _Ch_traits
, _Ch_alloc
>& __s
,
1959 match_results
<typename basic_string
<_Ch_type
,
1960 _Ch_traits
, _Ch_alloc
>::const_iterator
, _Alloc
>& __m
,
1961 const basic_regex
<_Ch_type
, _Rx_traits
>& __re
,
1962 regex_constants::match_flag_type __flags
1963 = regex_constants::match_default
)
1964 { return regex_match(__s
.begin(), __s
.end(), __m
, __re
, __flags
); }
1967 * @brief Indicates if there is a match between the regular expression @p e
1968 * and a C-style null-terminated string.
1970 * @param __s The C-style null-terminated string to match.
1971 * @param __re The regular expression.
1972 * @param __f Controls how the regular expression is matched.
1974 * @retval true A match exists.
1975 * @retval false Otherwise.
1977 * @throws an exception of type regex_error.
1979 template<typename _Ch_type
, class _Rx_traits
>
1981 regex_match(const _Ch_type
* __s
,
1982 const basic_regex
<_Ch_type
, _Rx_traits
>& __re
,
1983 regex_constants::match_flag_type __f
1984 = regex_constants::match_default
)
1985 { return regex_match(__s
, __s
+ _Rx_traits::length(__s
), __re
, __f
); }
1988 * @brief Indicates if there is a match between the regular expression @p e
1991 * @param __s [IN] The string to match.
1992 * @param __re [IN] The regular expression.
1993 * @param __flags [IN] Controls how the regular expression is matched.
1995 * @retval true A match exists.
1996 * @retval false Otherwise.
1998 * @throws an exception of type regex_error.
2000 template<typename _Ch_traits
, typename _Str_allocator
,
2001 typename _Ch_type
, typename _Rx_traits
>
2003 regex_match(const basic_string
<_Ch_type
, _Ch_traits
, _Str_allocator
>& __s
,
2004 const basic_regex
<_Ch_type
, _Rx_traits
>& __re
,
2005 regex_constants::match_flag_type __flags
2006 = regex_constants::match_default
)
2007 { return regex_match(__s
.begin(), __s
.end(), __re
, __flags
); }
2009 // [7.11.3] Function template regex_search
2011 * Searches for a regular expression within a range.
2012 * @param __first [IN] The start of the string to search.
2013 * @param __last [IN] One-past-the-end of the string to search.
2014 * @param __m [OUT] The match results.
2015 * @param __re [IN] The regular expression to search for.
2016 * @param __flags [IN] Search policy flags.
2017 * @retval true A match was found within the string.
2018 * @retval false No match was found within the string, the content of %m is
2021 * @throws an exception of type regex_error.
2023 * @todo Implement this function.
2025 template<typename _Bi_iter
, typename _Alloc
,
2026 typename _Ch_type
, typename _Rx_traits
>
2028 regex_search(_Bi_iter __first
, _Bi_iter __last
,
2029 match_results
<_Bi_iter
, _Alloc
>& __m
,
2030 const basic_regex
<_Ch_type
, _Rx_traits
>& __re
,
2031 regex_constants::match_flag_type __flags
2032 = regex_constants::match_default
)
2036 * Searches for a regular expression within a range.
2037 * @param __first [IN] The start of the string to search.
2038 * @param __last [IN] One-past-the-end of the string to search.
2039 * @param __re [IN] The regular expression to search for.
2040 * @param __flags [IN] Search policy flags.
2041 * @retval true A match was found within the string.
2042 * @retval false No match was found within the string.
2045 * @throws an exception of type regex_error.
2047 template<typename _Bi_iter
, typename _Ch_type
, typename _Rx_traits
>
2049 regex_search(_Bi_iter __first
, _Bi_iter __last
,
2050 const basic_regex
<_Ch_type
, _Rx_traits
>& __re
,
2051 regex_constants::match_flag_type __flags
2052 = regex_constants::match_default
)
2054 match_results
<_Bi_iter
> __what
;
2055 return regex_search(__first
, __last
, __what
, __re
, __flags
);
2059 * @brief Searches for a regular expression within a C-string.
2060 * @param __s [IN] A C-string to search for the regex.
2061 * @param __m [OUT] The set of regex matches.
2062 * @param __e [IN] The regex to search for in @p s.
2063 * @param __f [IN] The search flags.
2064 * @retval true A match was found within the string.
2065 * @retval false No match was found within the string, the content of %m is
2069 * @throws an exception of type regex_error.
2071 template<typename _Ch_type
, class _Alloc
, class _Rx_traits
>
2073 regex_search(const _Ch_type
* __s
,
2074 match_results
<const _Ch_type
*, _Alloc
>& __m
,
2075 const basic_regex
<_Ch_type
, _Rx_traits
>& __e
,
2076 regex_constants::match_flag_type __f
2077 = regex_constants::match_default
)
2078 { return regex_search(__s
, __s
+ _Rx_traits::length(__s
), __m
, __e
, __f
); }
2081 * @brief Searches for a regular expression within a C-string.
2082 * @param __s [IN] The C-string to search.
2083 * @param __e [IN] The regular expression to search for.
2084 * @param __f [IN] Search policy flags.
2085 * @retval true A match was found within the string.
2086 * @retval false No match was found within the string.
2089 * @throws an exception of type regex_error.
2091 template<typename _Ch_type
, typename _Rx_traits
>
2093 regex_search(const _Ch_type
* __s
,
2094 const basic_regex
<_Ch_type
, _Rx_traits
>& __e
,
2095 regex_constants::match_flag_type __f
2096 = regex_constants::match_default
)
2097 { return regex_search(__s
, __s
+ _Rx_traits::length(__s
), __e
, __f
); }
2100 * @brief Searches for a regular expression within a string.
2101 * @param __s [IN] The string to search.
2102 * @param __e [IN] The regular expression to search for.
2103 * @param __flags [IN] Search policy flags.
2104 * @retval true A match was found within the string.
2105 * @retval false No match was found within the string.
2108 * @throws an exception of type regex_error.
2110 template<typename _Ch_traits
, typename _String_allocator
,
2111 typename _Ch_type
, typename _Rx_traits
>
2113 regex_search(const basic_string
<_Ch_type
, _Ch_traits
,
2114 _String_allocator
>& __s
,
2115 const basic_regex
<_Ch_type
, _Rx_traits
>& __e
,
2116 regex_constants::match_flag_type __flags
2117 = regex_constants::match_default
)
2118 { return regex_search(__s
.begin(), __s
.end(), __e
, __flags
); }
2121 * @brief Searches for a regular expression within a string.
2122 * @param __s [IN] A C++ string to search for the regex.
2123 * @param __m [OUT] The set of regex matches.
2124 * @param __e [IN] The regex to search for in @p s.
2125 * @param __f [IN] The search flags.
2126 * @retval true A match was found within the string.
2127 * @retval false No match was found within the string, the content of %m is
2130 * @throws an exception of type regex_error.
2132 template<typename _Ch_traits
, typename _Ch_alloc
,
2133 typename _Alloc
, typename _Ch_type
,
2134 typename _Rx_traits
>
2136 regex_search(const basic_string
<_Ch_type
, _Ch_traits
, _Ch_alloc
>& __s
,
2137 match_results
<typename basic_string
<_Ch_type
,
2138 _Ch_traits
, _Ch_alloc
>::const_iterator
, _Alloc
>& __m
,
2139 const basic_regex
<_Ch_type
, _Rx_traits
>& __e
,
2140 regex_constants::match_flag_type __f
2141 = regex_constants::match_default
)
2142 { return regex_search(__s
.begin(), __s
.end(), __m
, __e
, __f
); }
2144 // std [28.11.4] Function template regex_replace
2155 * @throws an exception of type regex_error.
2157 * @todo Implement this function.
2159 template<typename _Out_iter
, typename _Bi_iter
,
2160 typename _Rx_traits
, typename _Ch_type
>
2162 regex_replace(_Out_iter __out
, _Bi_iter __first
, _Bi_iter __last
,
2163 const basic_regex
<_Ch_type
, _Rx_traits
>& __e
,
2164 const basic_string
<_Ch_type
>& __fmt
,
2165 regex_constants::match_flag_type __flags
2166 = regex_constants::match_default
)
2176 * @returns a copy of string @p s with replacements.
2178 * @throws an exception of type regex_error.
2180 template<typename _Rx_traits
, typename _Ch_type
>
2181 inline basic_string
<_Ch_type
>
2182 regex_replace(const basic_string
<_Ch_type
>& __s
,
2183 const basic_regex
<_Ch_type
, _Rx_traits
>& __e
,
2184 const basic_string
<_Ch_type
>& __fmt
,
2185 regex_constants::match_flag_type __flags
2186 = regex_constants::match_default
)
2188 basic_string
<_Ch_type
> __result
;
2189 regex_replace(std::back_inserter(__result
),
2190 __s
.begin(), __s
.end(), __e
, __fmt
, __flags
);
2196 // std [28.12] Class template regex_iterator
2198 * An iterator adaptor that will provide repeated calls of regex_search over
2199 * a range until no more matches remain.
2201 template<typename _Bi_iter
,
2202 typename _Ch_type
= typename iterator_traits
<_Bi_iter
>::value_type
,
2203 typename _Rx_traits
= regex_traits
<_Ch_type
> >
2204 class regex_iterator
2207 typedef basic_regex
<_Ch_type
, _Rx_traits
> regex_type
;
2208 typedef match_results
<_Bi_iter
> value_type
;
2209 typedef std::ptrdiff_t difference_type
;
2210 typedef const value_type
* pointer
;
2211 typedef const value_type
& reference
;
2212 typedef std::forward_iterator_tag iterator_category
;
2215 * @brief Provides a singular iterator, useful for indicating
2216 * one-past-the-end of a range.
2217 * @todo Implement this function.
2223 * Constructs a %regex_iterator...
2224 * @param __a [IN] The start of a text range to search.
2225 * @param __b [IN] One-past-the-end of the text range to search.
2226 * @param __re [IN] The regular expression to match.
2227 * @param __m [IN] Policy flags for match rules.
2228 * @todo Implement this function.
2231 regex_iterator(_Bi_iter __a
, _Bi_iter __b
, const regex_type
& __re
,
2232 regex_constants::match_flag_type __m
2233 = regex_constants::match_default
);
2236 * Copy constructs a %regex_iterator.
2237 * @todo Implement this function.
2240 regex_iterator(const regex_iterator
& __rhs
);
2243 * @todo Implement this function.
2247 operator=(const regex_iterator
& __rhs
);
2250 * @todo Implement this function.
2254 operator==(const regex_iterator
& __rhs
);
2257 * @todo Implement this function.
2261 operator!=(const regex_iterator
& __rhs
);
2264 * @todo Implement this function.
2271 * @todo Implement this function.
2278 * @todo Implement this function.
2285 * @todo Implement this function.
2292 // these members are shown for exposition only:
2295 const regex_type
* pregex
;
2296 regex_constants::match_flag_type flags
;
2297 match_results
<_Bi_iter
> match
;
2300 typedef regex_iterator
<const char*> cregex_iterator
;
2301 typedef regex_iterator
<string::const_iterator
> sregex_iterator
;
2302 #ifdef _GLIBCXX_USE_WCHAR_T
2303 typedef regex_iterator
<const wchar_t*> wcregex_iterator
;
2304 typedef regex_iterator
<wstring::const_iterator
> wsregex_iterator
;
2307 // [7.12.2] Class template regex_token_iterator
2309 * Iterates over submatches in a range (or @a splits a text string).
2311 * The purpose of this iterator is to enumerate all, or all specified,
2312 * matches of a regular expression within a text range. The dereferenced
2313 * value of an iterator of this class is a std::sub_match object.
2315 template<typename _Bi_iter
,
2316 typename _Ch_type
= typename iterator_traits
<_Bi_iter
>::value_type
,
2317 typename _Rx_traits
= regex_traits
<_Ch_type
> >
2318 class regex_token_iterator
2321 typedef basic_regex
<_Ch_type
, _Rx_traits
> regex_type
;
2322 typedef sub_match
<_Bi_iter
> value_type
;
2323 typedef std::ptrdiff_t difference_type
;
2324 typedef const value_type
* pointer
;
2325 typedef const value_type
& reference
;
2326 typedef std::forward_iterator_tag iterator_category
;
2330 * @brief Default constructs a %regex_token_iterator.
2331 * @todo Implement this function.
2333 * A default-constructed %regex_token_iterator is a singular iterator
2334 * that will compare equal to the one-past-the-end value for any
2335 * iterator of the same type.
2337 regex_token_iterator();
2340 * Constructs a %regex_token_iterator...
2341 * @param __a [IN] The start of the text to search.
2342 * @param __b [IN] One-past-the-end of the text to search.
2343 * @param __re [IN] The regular expression to search for.
2344 * @param __submatch [IN] Which submatch to return. There are some
2345 * special values for this parameter:
2346 * - -1 each enumerated subexpression does NOT
2347 * match the regular expression (aka field
2349 * - 0 the entire string matching the
2350 * subexpression is returned for each match
2352 * - >0 enumerates only the indicated
2353 * subexpression from a match within the text.
2354 * @param __m [IN] Policy flags for match rules.
2356 * @todo Implement this function.
2359 regex_token_iterator(_Bi_iter __a
, _Bi_iter __b
, const regex_type
& __re
,
2361 regex_constants::match_flag_type __m
2362 = regex_constants::match_default
);
2365 * Constructs a %regex_token_iterator...
2366 * @param __a [IN] The start of the text to search.
2367 * @param __b [IN] One-past-the-end of the text to search.
2368 * @param __re [IN] The regular expression to search for.
2369 * @param __submatches [IN] A list of subexpressions to return for each
2370 * regular expression match within the text.
2371 * @param __m [IN] Policy flags for match rules.
2373 * @todo Implement this function.
2376 regex_token_iterator(_Bi_iter __a
, _Bi_iter __b
,
2377 const regex_type
& __re
,
2378 const std::vector
<int>& __submatches
,
2379 regex_constants::match_flag_type __m
2380 = regex_constants::match_default
);
2383 * Constructs a %regex_token_iterator...
2384 * @param __a [IN] The start of the text to search.
2385 * @param __b [IN] One-past-the-end of the text to search.
2386 * @param __re [IN] The regular expression to search for.
2387 * @param __submatches [IN] A list of subexpressions to return for each
2388 * regular expression match within the text.
2389 * @param __m [IN] Policy flags for match rules.
2391 * @todo Implement this function.
2394 template<std::size_t _Nm
>
2395 regex_token_iterator(_Bi_iter __a
, _Bi_iter __b
,
2396 const regex_type
& __re
,
2397 const int (&__submatches
)[_Nm
],
2398 regex_constants::match_flag_type __m
2399 = regex_constants::match_default
);
2402 * @brief Copy constructs a %regex_token_iterator.
2403 * @param __rhs [IN] A %regex_token_iterator to copy.
2404 * @todo Implement this function.
2406 regex_token_iterator(const regex_token_iterator
& __rhs
);
2409 * @brief Assigns a %regex_token_iterator to another.
2410 * @param __rhs [IN] A %regex_token_iterator to copy.
2411 * @todo Implement this function.
2413 regex_token_iterator
&
2414 operator=(const regex_token_iterator
& __rhs
);
2417 * @brief Compares a %regex_token_iterator to another for equality.
2418 * @todo Implement this function.
2421 operator==(const regex_token_iterator
& __rhs
);
2424 * @brief Compares a %regex_token_iterator to another for inequality.
2425 * @todo Implement this function.
2428 operator!=(const regex_token_iterator
& __rhs
);
2431 * @brief Dereferences a %regex_token_iterator.
2432 * @todo Implement this function.
2438 * @brief Selects a %regex_token_iterator member.
2439 * @todo Implement this function.
2445 * @brief Increments a %regex_token_iterator.
2446 * @todo Implement this function.
2448 regex_token_iterator
&
2452 * @brief Postincrements a %regex_token_iterator.
2453 * @todo Implement this function.
2455 regex_token_iterator
2458 private: // data members for exposition only:
2459 typedef regex_iterator
<_Bi_iter
, _Ch_type
, _Rx_traits
> position_iterator
;
2461 position_iterator __position
;
2462 const value_type
* __result
;
2463 value_type __suffix
;
2465 std::vector
<int> __subs
;
2468 /** @brief Token iterator for C-style NULL-terminated strings. */
2469 typedef regex_token_iterator
<const char*> cregex_token_iterator
;
2471 /** @brief Token iterator for standard strings. */
2472 typedef regex_token_iterator
<string::const_iterator
> sregex_token_iterator
;
2474 #ifdef _GLIBCXX_USE_WCHAR_T
2475 /** @brief Token iterator for C-style NULL-terminated wide strings. */
2476 typedef regex_token_iterator
<const wchar_t*> wcregex_token_iterator
;
2478 /** @brief Token iterator for standard wide-character strings. */
2479 typedef regex_token_iterator
<wstring::const_iterator
> wsregex_token_iterator
;
2483 _GLIBCXX_END_NAMESPACE_VERSION