Merge from mainline (168000:168310).
[official-gcc/graphite-test-results.git] / libstdc++-v3 / include / bits / regex.h
blobab05fc2d9d03b4047b69a54bba84b5403e8bd6f8
1 // class template regex -*- C++ -*-
3 // Copyright (C) 2010 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
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/>.
25 /**
26 * @file bits/regex.h
27 * This is an internal header file, included by other library headers.
28 * Do not attempt to use it directly. @headername{regex}
31 _GLIBCXX_BEGIN_NAMESPACE(std)
33 /**
34 * @defgroup regex Regular Expressions
35 * A facility for performing regular expression pattern matching.
37 //@{
39 // [7.7] Class regex_traits
40 /**
41 * @brief Describes aspects of a regular expression.
43 * A regular expression traits class that satisfies the requirements of
44 * section [28.7].
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>
51 struct regex_traits
53 public:
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;
59 public:
60 /**
61 * @brief Constructs a default traits object.
63 regex_traits()
64 { }
66 /**
67 * @brief Gives the length of a C-style string starting at @p __p.
69 * @param __p a pointer to the start of a character sequence.
71 * @returns the number of characters between @p *__p and the first
72 * default-initialized value of type @p char_type. In other words, uses
73 * the C-string algorithm for determining the length of a sequence of
74 * characters.
76 static std::size_t
77 length(const char_type* __p)
78 { return string_type::traits_type::length(__p); }
80 /**
81 * @brief Performs the identity translation.
83 * @param c A character to the locale-specific character set.
85 * @returns c.
87 char_type
88 translate(char_type __c) const
89 { return __c; }
91 /**
92 * @brief Translates a character into a case-insensitive equivalent.
94 * @param c A character to the locale-specific character set.
96 * @returns the locale-specific lower-case equivalent of c.
97 * @throws std::bad_cast if the imbued locale does not support the ctype
98 * facet.
100 char_type
101 translate_nocase(char_type __c) const
103 using std::ctype;
104 using std::use_facet;
105 return use_facet<ctype<char_type> >(_M_locale).tolower(__c);
109 * @brief Gets a sort key for a character sequence.
111 * @param first beginning of the character sequence.
112 * @param last one-past-the-end of the character sequence.
114 * Returns a sort key for the character sequence designated by the
115 * iterator range [F1, F2) such that if the character sequence [G1, G2)
116 * sorts before the character sequence [H1, H2) then
117 * v.transform(G1, G2) < v.transform(H1, H2).
119 * What this really does is provide a more efficient way to compare a
120 * string to multiple other strings in locales with fancy collation
121 * rules and equivalence classes.
123 * @returns a locale-specific sort key equivalent to the input range.
125 * @throws std::bad_cast if the current locale does not have a collate
126 * facet.
128 template<typename _Fwd_iter>
129 string_type
130 transform(_Fwd_iter __first, _Fwd_iter __last) const
132 using std::collate;
133 using std::use_facet;
134 const collate<_Ch_type>& __c(use_facet<
135 collate<_Ch_type> >(_M_locale));
136 string_type __s(__first, __last);
137 return __c.transform(__s.data(), __s.data() + __s.size());
141 * @brief Gets a sort key for a character sequence, independant of case.
143 * @param first beginning of the character sequence.
144 * @param last one-past-the-end of the character sequence.
146 * Effects: if typeid(use_facet<collate<_Ch_type> >) ==
147 * typeid(collate_byname<_Ch_type>) and the form of the sort key
148 * returned by collate_byname<_Ch_type>::transform(first, last) is known
149 * and can be converted into a primary sort key then returns that key,
150 * otherwise returns an empty string.
152 * @todo Implement this function.
154 template<typename _Fwd_iter>
155 string_type
156 transform_primary(_Fwd_iter __first, _Fwd_iter __last) const
157 { return string_type(); }
160 * @brief Gets a collation element by name.
162 * @param first beginning of the collation element name.
163 * @param last one-past-the-end of the collation element name.
165 * @returns a sequence of one or more characters that represents the
166 * collating element consisting of the character sequence designated by
167 * the iterator range [first, last). Returns an empty string if the
168 * character sequence is not a valid collating element.
170 * @todo Implement this function.
172 template<typename _Fwd_iter>
173 string_type
174 lookup_collatename(_Fwd_iter __first, _Fwd_iter __last) const
175 { return string_type(); }
178 * @brief Maps one or more characters to a named character
179 * classification.
181 * @param first beginning of the character sequence.
182 * @param last one-past-the-end of the character sequence.
183 * @param icase ignores the case of the classification name.
185 * @returns an unspecified value that represents the character
186 * classification named by the character sequence designated by the
187 * iterator range [first, last). If @p icase is true, the returned mask
188 * identifies the classification regardless of the case of the characters
189 * to be matched (for example, [[:lower:]] is the same as [[:alpha:]]),
190 * otherwise a case-dependant classification is returned. The value
191 * returned shall be independent of the case of the characters in the
192 * character sequence. If the name is not recognized then returns a value
193 * that compares equal to 0.
195 * At least the following names (or their wide-character equivalent) are
196 * supported.
197 * - d
198 * - w
199 * - s
200 * - alnum
201 * - alpha
202 * - blank
203 * - cntrl
204 * - digit
205 * - graph
206 * - lower
207 * - print
208 * - punct
209 * - space
210 * - upper
211 * - xdigit
213 * @todo Implement this function.
215 template<typename _Fwd_iter>
216 char_class_type
217 lookup_classname(_Fwd_iter __first, _Fwd_iter __last,
218 bool __icase = false) const
219 { return 0; }
222 * @brief Determines if @p c is a member of an identified class.
224 * @param c a character.
225 * @param f a class type (as returned from lookup_classname).
227 * @returns true if the character @p c is a member of the classification
228 * represented by @p f, false otherwise.
230 * @throws std::bad_cast if the current locale does not have a ctype
231 * facet.
233 bool
234 isctype(_Ch_type __c, char_class_type __f) const;
237 * @brief Converts a digit to an int.
239 * @param ch a character representing a digit.
240 * @param radix the radix if the numeric conversion (limited to 8, 10,
241 * or 16).
243 * @returns the value represented by the digit ch in base radix if the
244 * character ch is a valid digit in base radix; otherwise returns -1.
247 value(_Ch_type __ch, int __radix) const;
250 * @brief Imbues the regex_traits object with a copy of a new locale.
252 * @param loc A locale.
254 * @returns a copy of the previous locale in use by the regex_traits
255 * object.
257 * @note Calling imbue with a different locale than the one currently in
258 * use invalidates all cached data held by *this.
260 locale_type
261 imbue(locale_type __loc)
263 std::swap(_M_locale, __loc);
264 return __loc;
268 * @brief Gets a copy of the current locale in use by the regex_traits
269 * object.
271 locale_type
272 getloc() const
273 { return _M_locale; }
275 protected:
276 locale_type _M_locale;
279 template<typename _Ch_type>
280 bool
281 regex_traits<_Ch_type>::
282 isctype(_Ch_type __c, char_class_type __f) const
284 using std::ctype;
285 using std::use_facet;
286 const ctype<_Ch_type>& __ctype(use_facet<
287 ctype<_Ch_type> >(_M_locale));
289 if (__ctype.is(__f, __c))
290 return true;
292 // special case of underscore in [[:w:]]
293 if (__c == __ctype.widen('_'))
295 const char __wb[] = "w";
296 char_class_type __wt = this->lookup_classname(__wb,
297 __wb + sizeof(__wb));
298 if (__f | __wt)
299 return true;
302 // special case of [[:space:]] in [[:blank:]]
303 if (__ctype.is(std::ctype_base::space, __c))
305 const char __bb[] = "blank";
306 char_class_type __bt = this->lookup_classname(__bb,
307 __bb + sizeof(__bb));
308 if (__f | __bt)
309 return true;
312 return false;
315 template<typename _Ch_type>
317 regex_traits<_Ch_type>::
318 value(_Ch_type __ch, int __radix) const
320 std::basic_istringstream<_Ch_type> __is(string_type(1, __ch));
321 int __v;
322 if (__radix == 8)
323 __is >> std::oct;
324 else if (__radix == 16)
325 __is >> std::hex;
326 __is >> __v;
327 return __is.fail() ? -1 : __v;
330 // [7.8] Class basic_regex
332 * Objects of specializations of this class represent regular expressions
333 * constructed from sequences of character type @p _Ch_type.
335 * Storage for the regular expression is allocated and deallocated as
336 * necessary by the member functions of this class.
338 template<typename _Ch_type, typename _Rx_traits = regex_traits<_Ch_type> >
339 class basic_regex
341 public:
342 // types:
343 typedef _Ch_type value_type;
344 typedef regex_constants::syntax_option_type flag_type;
345 typedef typename _Rx_traits::locale_type locale_type;
346 typedef typename _Rx_traits::string_type string_type;
349 * @name Constants
350 * std [28.8.1](1)
352 //@{
353 static constexpr regex_constants::syntax_option_type icase
354 = regex_constants::icase;
355 static constexpr regex_constants::syntax_option_type nosubs
356 = regex_constants::nosubs;
357 static constexpr regex_constants::syntax_option_type optimize
358 = regex_constants::optimize;
359 static constexpr regex_constants::syntax_option_type collate
360 = regex_constants::collate;
361 static constexpr regex_constants::syntax_option_type ECMAScript
362 = regex_constants::ECMAScript;
363 static constexpr regex_constants::syntax_option_type basic
364 = regex_constants::basic;
365 static constexpr regex_constants::syntax_option_type extended
366 = regex_constants::extended;
367 static constexpr regex_constants::syntax_option_type awk
368 = regex_constants::awk;
369 static constexpr regex_constants::syntax_option_type grep
370 = regex_constants::grep;
371 static constexpr regex_constants::syntax_option_type egrep
372 = regex_constants::egrep;
373 //@}
375 // [7.8.2] construct/copy/destroy
377 * Constructs a basic regular expression that does not match any
378 * character sequence.
380 basic_regex()
381 : _M_flags(regex_constants::ECMAScript),
382 _M_automaton(__regex::__compile<const _Ch_type*, _Rx_traits>(0, 0,
383 _M_traits, _M_flags))
387 * @brief Constructs a basic regular expression from the sequence
388 * [p, p + char_traits<_Ch_type>::length(p)) interpreted according to the
389 * flags in @p f.
391 * @param p A pointer to the start of a C-style null-terminated string
392 * containing a regular expression.
393 * @param f Flags indicating the syntax rules and options.
395 * @throws regex_error if @p p is not a valid regular expression.
397 explicit
398 basic_regex(const _Ch_type* __p,
399 flag_type __f = regex_constants::ECMAScript)
400 : _M_flags(__f),
401 _M_automaton(__regex::__compile(__p, __p + _Rx_traits::length(__p),
402 _M_traits, _M_flags))
406 * @brief Constructs a basic regular expression from the sequence
407 * [p, p + len) interpreted according to the flags in @p f.
409 * @param p A pointer to the start of a string containing a regular
410 * expression.
411 * @param len The length of the string containing the regular expression.
412 * @param f Flags indicating the syntax rules and options.
414 * @throws regex_error if @p p is not a valid regular expression.
416 basic_regex(const _Ch_type* __p, std::size_t __len, flag_type __f)
417 : _M_flags(__f),
418 _M_automaton(__regex::__compile(__p, __p + __len, _M_traits, _M_flags))
422 * @brief Copy-constructs a basic regular expression.
424 * @param rhs A @p regex object.
426 basic_regex(const basic_regex& __rhs)
427 : _M_flags(__rhs._M_flags), _M_traits(__rhs._M_traits),
428 _M_automaton(__rhs._M_automaton)
432 * @brief Move-constructs a basic regular expression.
434 * @param rhs A @p regex object.
436 basic_regex(const basic_regex&& __rhs)
437 : _M_flags(__rhs._M_flags), _M_traits(__rhs._M_traits),
438 _M_automaton(std::move(__rhs._M_automaton))
442 * @brief Constructs a basic regular expression from the string
443 * @p s interpreted according to the flags in @p f.
445 * @param s A string containing a regular expression.
446 * @param f Flags indicating the syntax rules and options.
448 * @throws regex_error if @p s is not a valid regular expression.
450 template<typename _Ch_traits, typename _Ch_alloc>
451 explicit
452 basic_regex(const std::basic_string<_Ch_type, _Ch_traits,
453 _Ch_alloc>& __s,
454 flag_type __f = regex_constants::ECMAScript)
455 : _M_flags(__f),
456 _M_automaton(__regex::__compile(__s.begin(), __s.end(),
457 _M_traits, _M_flags))
461 * @brief Constructs a basic regular expression from the range
462 * [first, last) interpreted according to the flags in @p f.
464 * @param first The start of a range containing a valid regular
465 * expression.
466 * @param last The end of a range containing a valid regular
467 * expression.
468 * @param f The format flags of the regular expression.
470 * @throws regex_error if @p [first, last) is not a valid regular
471 * expression.
473 template<typename _InputIterator>
474 basic_regex(_InputIterator __first, _InputIterator __last,
475 flag_type __f = regex_constants::ECMAScript)
476 : _M_flags(__f),
477 _M_automaton(__regex::__compile(__first, __last, _M_traits, _M_flags))
481 * @brief Constructs a basic regular expression from an initializer list.
483 * @param l The initializer list.
484 * @param f The format flags of the regular expression.
486 * @throws regex_error if @p l is not a valid regular expression.
488 basic_regex(initializer_list<_Ch_type> __l,
489 flag_type __f = regex_constants::ECMAScript)
490 : _M_flags(__f),
491 _M_automaton(__regex::__compile(__l.begin(), __l.end(),
492 _M_traits, _M_flags))
496 * @brief Destroys a basic regular expression.
498 ~basic_regex()
502 * @brief Assigns one regular expression to another.
504 basic_regex&
505 operator=(const basic_regex& __rhs)
506 { return this->assign(__rhs); }
509 * @brief Move-assigns one regular expression to another.
511 basic_regex&
512 operator=(basic_regex&& __rhs)
513 { return this->assign(std::move(__rhs)); }
516 * @brief Replaces a regular expression with a new one constructed from
517 * a C-style null-terminated string.
519 * @param A pointer to the start of a null-terminated C-style string
520 * containing a regular expression.
522 basic_regex&
523 operator=(const _Ch_type* __p)
524 { return this->assign(__p, flags()); }
527 * @brief Replaces a regular expression with a new one constructed from
528 * a string.
530 * @param A pointer to a string containing a regular expression.
532 template<typename _Ch_typeraits, typename _Allocator>
533 basic_regex&
534 operator=(const basic_string<_Ch_type, _Ch_typeraits, _Allocator>& __s)
535 { return this->assign(__s, flags()); }
537 // [7.8.3] assign
539 * @brief the real assignment operator.
541 * @param rhs Another regular expression object.
543 basic_regex&
544 assign(const basic_regex& __rhs)
546 basic_regex __tmp(__rhs);
547 this->swap(__tmp);
548 return *this;
552 * @brief The move-assignment operator.
554 * @param rhs Another regular expression object.
556 basic_regex&
557 assign(basic_regex&& __rhs)
559 basic_regex __tmp(std::move(__rhs));
560 this->swap(__tmp);
561 return *this;
565 * @brief Assigns a new regular expression to a regex object from a
566 * C-style null-terminated string containing a regular expression
567 * pattern.
569 * @param p A pointer to a C-style null-terminated string containing
570 * a regular expression pattern.
571 * @param flags Syntax option flags.
573 * @throws regex_error if p does not contain a valid regular expression
574 * pattern interpreted according to @p flags. If regex_error is thrown,
575 * *this remains unchanged.
577 basic_regex&
578 assign(const _Ch_type* __p,
579 flag_type __flags = regex_constants::ECMAScript)
580 { return this->assign(string_type(__p), __flags); }
583 * @brief Assigns a new regular expression to a regex object from a
584 * C-style string containing a regular expression pattern.
586 * @param p A pointer to a C-style string containing a
587 * regular expression pattern.
588 * @param len The length of the regular expression pattern string.
589 * @param flags Syntax option flags.
591 * @throws regex_error if p does not contain a valid regular expression
592 * pattern interpreted according to @p flags. If regex_error is thrown,
593 * *this remains unchanged.
595 basic_regex&
596 assign(const _Ch_type* __p, std::size_t __len, flag_type __flags)
597 { return this->assign(string_type(__p, __len), __flags); }
600 * @brief Assigns a new regular expression to a regex object from a
601 * string containing a regular expression pattern.
603 * @param s A string containing a regular expression pattern.
604 * @param flags Syntax option flags.
606 * @throws regex_error if p does not contain a valid regular expression
607 * pattern interpreted according to @p flags. If regex_error is thrown,
608 * *this remains unchanged.
610 template<typename _Ch_typeraits, typename _Allocator>
611 basic_regex&
612 assign(const basic_string<_Ch_type, _Ch_typeraits, _Allocator>& __s,
613 flag_type __f = regex_constants::ECMAScript)
615 basic_regex __tmp(__s, __f);
616 this->swap(__tmp);
617 return *this;
621 * @brief Assigns a new regular expression to a regex object.
623 * @param first The start of a range containing a valid regular
624 * expression.
625 * @param last The end of a range containing a valid regular
626 * expression.
627 * @param flags Syntax option flags.
629 * @throws regex_error if p does not contain a valid regular expression
630 * pattern interpreted according to @p flags. If regex_error is thrown,
631 * the object remains unchanged.
633 template<typename _InputIterator>
634 basic_regex&
635 assign(_InputIterator __first, _InputIterator __last,
636 flag_type __flags = regex_constants::ECMAScript)
637 { return this->assign(string_type(__first, __last), __flags); }
640 * @brief Assigns a new regular expression to a regex object.
642 * @param l An initializer list representing a regular expression.
643 * @param flags Syntax option flags.
645 * @throws regex_error if @p l does not contain a valid regular
646 * expression pattern interpreted according to @p flags. If regex_error
647 * is thrown, the object remains unchanged.
649 basic_regex&
650 assign(initializer_list<_Ch_type> __l,
651 flag_type __f = regex_constants::ECMAScript)
652 { return this->assign(__l.begin(), __l.end(), __f); }
654 // [7.8.4] const operations
656 * @brief Gets the number of marked subexpressions within the regular
657 * expression.
659 unsigned int
660 mark_count() const
661 { return _M_automaton->_M_sub_count() - 1; }
664 * @brief Gets the flags used to construct the regular expression
665 * or in the last call to assign().
667 flag_type
668 flags() const
669 { return _M_flags; }
671 // [7.8.5] locale
673 * @brief Imbues the regular expression object with the given locale.
675 * @param loc A locale.
677 locale_type
678 imbue(locale_type __loc)
679 { return _M_traits.imbue(__loc); }
682 * @brief Gets the locale currently imbued in the regular expression
683 * object.
685 locale_type
686 getloc() const
687 { return _M_traits.getloc(); }
689 // [7.8.6] swap
691 * @brief Swaps the contents of two regular expression objects.
693 * @param rhs Another regular expression object.
695 void
696 swap(basic_regex& __rhs)
698 std::swap(_M_flags, __rhs._M_flags);
699 std::swap(_M_traits, __rhs._M_traits);
700 std::swap(_M_automaton, __rhs._M_automaton);
703 #ifdef _GLIBCXX_DEBUG
704 void
705 _M_dot(std::ostream& __ostr)
706 { _M_automaton->_M_dot(__ostr); }
707 #endif
709 const __regex::_AutomatonPtr&
710 _M_get_automaton() const
711 { return _M_automaton; }
713 protected:
714 flag_type _M_flags;
715 _Rx_traits _M_traits;
716 __regex::_AutomatonPtr _M_automaton;
719 /** @brief Standard regular expressions. */
720 typedef basic_regex<char> regex;
721 #ifdef _GLIBCXX_USE_WCHAR_T
722 /** @brief Standard wide-character regular expressions. */
723 typedef basic_regex<wchar_t> wregex;
724 #endif
727 // [7.8.6] basic_regex swap
729 * @brief Swaps the contents of two regular expression objects.
730 * @param lhs First regular expression.
731 * @param rhs Second regular expression.
733 template<typename _Ch_type, typename _Rx_traits>
734 inline void
735 swap(basic_regex<_Ch_type, _Rx_traits>& __lhs,
736 basic_regex<_Ch_type, _Rx_traits>& __rhs)
737 { __lhs.swap(__rhs); }
740 // [7.9] Class template sub_match
742 * A sequence of characters matched by a particular marked sub-expression.
744 * An object of this class is essentially a pair of iterators marking a
745 * matched subexpression within a regular expression pattern match. Such
746 * objects can be converted to and compared with std::basic_string objects
747 * of a similar base character type as the pattern matched by the regular
748 * expression.
750 * The iterators that make up the pair are the usual half-open interval
751 * referencing the actual original pattern matched.
753 template<typename _BiIter>
754 class sub_match : public std::pair<_BiIter, _BiIter>
756 public:
757 typedef typename iterator_traits<_BiIter>::value_type value_type;
758 typedef typename iterator_traits<_BiIter>::difference_type
759 difference_type;
760 typedef _BiIter iterator;
761 typedef std::basic_string<value_type> string_type;
763 public:
764 bool matched;
767 * Gets the length of the matching sequence.
769 difference_type
770 length() const
771 { return this->matched ? std::distance(this->first, this->second) : 0; }
774 * @brief Gets the matching sequence as a string.
776 * @returns the matching sequence as a string.
778 * This is the implicit conversion operator. It is identical to the
779 * str() member function except that it will want to pop up in
780 * unexpected places and cause a great deal of confusion and cursing
781 * from the unwary.
783 operator string_type() const
785 return this->matched
786 ? string_type(this->first, this->second)
787 : string_type();
791 * @brief Gets the matching sequence as a string.
793 * @returns the matching sequence as a string.
795 string_type
796 str() const
798 return this->matched
799 ? string_type(this->first, this->second)
800 : string_type();
804 * @brief Compares this and another matched sequence.
806 * @param s Another matched sequence to compare to this one.
808 * @retval <0 this matched sequence will collate before @p s.
809 * @retval =0 this matched sequence is equivalent to @p s.
810 * @retval <0 this matched sequence will collate after @p s.
813 compare(const sub_match& __s) const
814 { return this->str().compare(__s.str()); }
817 * @brief Compares this sub_match to a string.
819 * @param s A string to compare to this sub_match.
821 * @retval <0 this matched sequence will collate before @p s.
822 * @retval =0 this matched sequence is equivalent to @p s.
823 * @retval <0 this matched sequence will collate after @p s.
826 compare(const string_type& __s) const
827 { return this->str().compare(__s); }
830 * @brief Compares this sub_match to a C-style string.
832 * @param s A C-style string to compare to this sub_match.
834 * @retval <0 this matched sequence will collate before @p s.
835 * @retval =0 this matched sequence is equivalent to @p s.
836 * @retval <0 this matched sequence will collate after @p s.
839 compare(const value_type* __s) const
840 { return this->str().compare(__s); }
844 /** @brief Standard regex submatch over a C-style null-terminated string. */
845 typedef sub_match<const char*> csub_match;
846 /** @brief Standard regex submatch over a standard string. */
847 typedef sub_match<string::const_iterator> ssub_match;
848 #ifdef _GLIBCXX_USE_WCHAR_T
849 /** @brief Regex submatch over a C-style null-terminated wide string. */
850 typedef sub_match<const wchar_t*> wcsub_match;
851 /** @brief Regex submatch over a standard wide string. */
852 typedef sub_match<wstring::const_iterator> wssub_match;
853 #endif
855 // [7.9.2] sub_match non-member operators
858 * @brief Tests the equivalence of two regular expression submatches.
859 * @param lhs First regular expression submatch.
860 * @param rhs Second regular expression submatch.
861 * @returns true if @a lhs is equivalent to @a rhs, false otherwise.
863 template<typename _BiIter>
864 inline bool
865 operator==(const sub_match<_BiIter>& __lhs,
866 const sub_match<_BiIter>& __rhs)
867 { return __lhs.compare(__rhs) == 0; }
870 * @brief Tests the inequivalence of two regular expression submatches.
871 * @param lhs First regular expression submatch.
872 * @param rhs Second regular expression submatch.
873 * @returns true if @a lhs is not equivalent to @a rhs, false otherwise.
875 template<typename _BiIter>
876 inline bool
877 operator!=(const sub_match<_BiIter>& __lhs,
878 const sub_match<_BiIter>& __rhs)
879 { return __lhs.compare(__rhs) != 0; }
882 * @brief Tests the ordering of two regular expression submatches.
883 * @param lhs First regular expression submatch.
884 * @param rhs Second regular expression submatch.
885 * @returns true if @a lhs precedes @a rhs, false otherwise.
887 template<typename _BiIter>
888 inline bool
889 operator<(const sub_match<_BiIter>& __lhs,
890 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 succeed @a rhs, false otherwise.
899 template<typename _BiIter>
900 inline bool
901 operator<=(const sub_match<_BiIter>& __lhs,
902 const sub_match<_BiIter>& __rhs)
903 { return __lhs.compare(__rhs) <= 0; }
906 * @brief Tests the ordering of two regular expression submatches.
907 * @param lhs First regular expression submatch.
908 * @param rhs Second regular expression submatch.
909 * @returns true if @a lhs does not precede @a rhs, false otherwise.
911 template<typename _BiIter>
912 inline bool
913 operator>=(const sub_match<_BiIter>& __lhs,
914 const sub_match<_BiIter>& __rhs)
915 { return __lhs.compare(__rhs) >= 0; }
918 * @brief Tests the ordering of two regular expression submatches.
919 * @param lhs First regular expression submatch.
920 * @param rhs Second regular expression submatch.
921 * @returns true if @a lhs succeeds @a rhs, false otherwise.
923 template<typename _BiIter>
924 inline bool
925 operator>(const sub_match<_BiIter>& __lhs,
926 const sub_match<_BiIter>& __rhs)
927 { return __lhs.compare(__rhs) > 0; }
930 * @brief Tests the equivalence of a string and a regular expression
931 * submatch.
932 * @param lhs A string.
933 * @param rhs A regular expression submatch.
934 * @returns true if @a lhs is equivalent to @a rhs, false otherwise.
936 template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
937 inline bool
938 operator==(const basic_string<
939 typename iterator_traits<_Bi_iter>::value_type,
940 _Ch_traits, _Ch_alloc>& __lhs,
941 const sub_match<_Bi_iter>& __rhs)
942 { return __lhs == __rhs.str(); }
945 * @brief Tests the inequivalence of a string and a regular expression
946 * submatch.
947 * @param lhs A string.
948 * @param rhs A regular expression submatch.
949 * @returns true if @a lhs is not equivalent to @a rhs, false otherwise.
951 template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
952 inline bool
953 operator!=(const basic_string<
954 typename iterator_traits<_Bi_iter>::value_type,
955 _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs)
956 { return __lhs != __rhs.str(); }
959 * @brief Tests the ordering of a string and a regular expression submatch.
960 * @param lhs A string.
961 * @param rhs A regular expression submatch.
962 * @returns true if @a lhs precedes @a rhs, false otherwise.
964 template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
965 inline bool
966 operator<(const basic_string<
967 typename iterator_traits<_Bi_iter>::value_type,
968 _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs)
969 { return __lhs < __rhs.str(); }
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 succeeds @a rhs, false otherwise.
977 template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
978 inline bool
979 operator>(const basic_string<
980 typename iterator_traits<_Bi_iter>::value_type,
981 _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs)
982 { return __lhs > __rhs.str(); }
985 * @brief Tests the ordering of a string and a regular expression submatch.
986 * @param lhs A string.
987 * @param rhs A regular expression submatch.
988 * @returns true if @a lhs does not precede @a rhs, false otherwise.
990 template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
991 inline bool
992 operator>=(const basic_string<
993 typename iterator_traits<_Bi_iter>::value_type,
994 _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs)
995 { return __lhs >= __rhs.str(); }
998 * @brief Tests the ordering of a string and a regular expression submatch.
999 * @param lhs A string.
1000 * @param rhs A regular expression submatch.
1001 * @returns true if @a lhs does not succeed @a rhs, false otherwise.
1003 template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
1004 inline bool
1005 operator<=(const basic_string<
1006 typename iterator_traits<_Bi_iter>::value_type,
1007 _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs)
1008 { return __lhs <= __rhs.str(); }
1011 * @brief Tests the equivalence of a regular expression submatch and a
1012 * string.
1013 * @param lhs A regular expression submatch.
1014 * @param rhs A string.
1015 * @returns true if @a lhs is equivalent to @a rhs, false otherwise.
1017 template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
1018 inline bool
1019 operator==(const sub_match<_Bi_iter>& __lhs,
1020 const basic_string<
1021 typename iterator_traits<_Bi_iter>::value_type,
1022 _Ch_traits, _Ch_alloc>& __rhs)
1023 { return __lhs.str() == __rhs; }
1026 * @brief Tests the inequivalence of a regular expression submatch and a
1027 * string.
1028 * @param lhs A regular expression submatch.
1029 * @param rhs A string.
1030 * @returns true if @a lhs is not equivalent to @a rhs, false otherwise.
1032 template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
1033 inline bool
1034 operator!=(const sub_match<_Bi_iter>& __lhs,
1035 const basic_string<
1036 typename iterator_traits<_Bi_iter>::value_type,
1037 _Ch_traits, _Ch_alloc>& __rhs)
1038 { return __lhs.str() != __rhs; }
1041 * @brief Tests the ordering of a regular expression submatch and a string.
1042 * @param lhs A regular expression submatch.
1043 * @param rhs A string.
1044 * @returns true if @a lhs precedes @a rhs, false otherwise.
1046 template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc>
1047 inline bool
1048 operator<(const sub_match<_Bi_iter>& __lhs,
1049 const basic_string<
1050 typename iterator_traits<_Bi_iter>::value_type,
1051 _Ch_traits, _Ch_alloc>& __rhs)
1052 { return __lhs.str() < __rhs; }
1055 * @brief Tests the ordering of a regular expression submatch and a string.
1056 * @param lhs A regular expression submatch.
1057 * @param rhs A string.
1058 * @returns true if @a lhs succeeds @a rhs, false otherwise.
1060 template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc>
1061 inline bool
1062 operator>(const sub_match<_Bi_iter>& __lhs,
1063 const basic_string<
1064 typename iterator_traits<_Bi_iter>::value_type,
1065 _Ch_traits, _Ch_alloc>& __rhs)
1066 { return __lhs.str() > __rhs; }
1069 * @brief Tests the ordering of a regular expression submatch and a string.
1070 * @param lhs A regular expression submatch.
1071 * @param rhs A string.
1072 * @returns true if @a lhs does not precede @a rhs, false otherwise.
1074 template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc>
1075 inline bool
1076 operator>=(const sub_match<_Bi_iter>& __lhs,
1077 const basic_string<
1078 typename iterator_traits<_Bi_iter>::value_type,
1079 _Ch_traits, _Ch_alloc>& __rhs)
1080 { return __lhs.str() >= __rhs; }
1083 * @brief Tests the ordering of a regular expression submatch and a string.
1084 * @param lhs A regular expression submatch.
1085 * @param rhs A string.
1086 * @returns true if @a lhs does not succeed @a rhs, false otherwise.
1088 template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc>
1089 inline bool
1090 operator<=(const sub_match<_Bi_iter>& __lhs,
1091 const basic_string<
1092 typename iterator_traits<_Bi_iter>::value_type,
1093 _Ch_traits, _Ch_alloc>& __rhs)
1094 { return __lhs.str() <= __rhs; }
1097 * @brief Tests the equivalence of a C string and a regular expression
1098 * submatch.
1099 * @param lhs A C string.
1100 * @param rhs A regular expression submatch.
1101 * @returns true if @a lhs is equivalent to @a rhs, false otherwise.
1103 template<typename _Bi_iter>
1104 inline bool
1105 operator==(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
1106 const sub_match<_Bi_iter>& __rhs)
1107 { return __lhs == __rhs.str(); }
1110 * @brief Tests the inequivalence of an iterator value and a regular
1111 * expression submatch.
1112 * @param lhs A regular expression submatch.
1113 * @param rhs A string.
1114 * @returns true if @a lhs is not equivalent to @a rhs, false otherwise.
1116 template<typename _Bi_iter>
1117 inline bool
1118 operator!=(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
1119 const sub_match<_Bi_iter>& __rhs)
1120 { return __lhs != __rhs.str(); }
1123 * @brief Tests the ordering of a string and a regular expression submatch.
1124 * @param lhs A string.
1125 * @param rhs A regular expression submatch.
1126 * @returns true if @a lhs precedes @a rhs, false otherwise.
1128 template<typename _Bi_iter>
1129 inline bool
1130 operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
1131 const sub_match<_Bi_iter>& __rhs)
1132 { return __lhs < __rhs.str(); }
1135 * @brief Tests the ordering of a string and a regular expression submatch.
1136 * @param lhs A string.
1137 * @param rhs A regular expression submatch.
1138 * @returns true if @a lhs succeeds @a rhs, false otherwise.
1140 template<typename _Bi_iter>
1141 inline bool
1142 operator>(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
1143 const sub_match<_Bi_iter>& __rhs)
1144 { return __lhs > __rhs.str(); }
1147 * @brief Tests the ordering of a string and a regular expression submatch.
1148 * @param lhs A string.
1149 * @param rhs A regular expression submatch.
1150 * @returns true if @a lhs does not precede @a rhs, false otherwise.
1152 template<typename _Bi_iter>
1153 inline bool
1154 operator>=(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
1155 const sub_match<_Bi_iter>& __rhs)
1156 { return __lhs >= __rhs.str(); }
1159 * @brief Tests the ordering of a string and a regular expression submatch.
1160 * @param lhs A string.
1161 * @param rhs A regular expression submatch.
1162 * @returns true if @a lhs does not succeed @a rhs, false otherwise.
1164 template<typename _Bi_iter>
1165 inline bool
1166 operator<=(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
1167 const sub_match<_Bi_iter>& __rhs)
1168 { return __lhs <= __rhs.str(); }
1171 * @brief Tests the equivalence of a regular expression submatch and a
1172 * string.
1173 * @param lhs A regular expression submatch.
1174 * @param rhs A pointer to a string?
1175 * @returns true if @a lhs is equivalent to @a rhs, false otherwise.
1177 template<typename _Bi_iter>
1178 inline bool
1179 operator==(const sub_match<_Bi_iter>& __lhs,
1180 typename iterator_traits<_Bi_iter>::value_type const* __rhs)
1181 { return __lhs.str() == __rhs; }
1184 * @brief Tests the inequivalence of a regular expression submatch and a
1185 * string.
1186 * @param lhs A regular expression submatch.
1187 * @param rhs A pointer to a string.
1188 * @returns true if @a lhs is not equivalent to @a rhs, false otherwise.
1190 template<typename _Bi_iter>
1191 inline bool
1192 operator!=(const sub_match<_Bi_iter>& __lhs,
1193 typename iterator_traits<_Bi_iter>::value_type const* __rhs)
1194 { return __lhs.str() != __rhs; }
1197 * @brief Tests the ordering of a regular expression submatch and a string.
1198 * @param lhs A regular expression submatch.
1199 * @param rhs A string.
1200 * @returns true if @a lhs precedes @a rhs, false otherwise.
1202 template<typename _Bi_iter>
1203 inline bool
1204 operator<(const sub_match<_Bi_iter>& __lhs,
1205 typename iterator_traits<_Bi_iter>::value_type const* __rhs)
1206 { return __lhs.str() < __rhs; }
1209 * @brief Tests the ordering of a regular expression submatch and a string.
1210 * @param lhs A regular expression submatch.
1211 * @param rhs A string.
1212 * @returns true if @a lhs succeeds @a rhs, false otherwise.
1214 template<typename _Bi_iter>
1215 inline bool
1216 operator>(const sub_match<_Bi_iter>& __lhs,
1217 typename iterator_traits<_Bi_iter>::value_type const* __rhs)
1218 { return __lhs.str() > __rhs; }
1221 * @brief Tests the ordering of a regular expression submatch and a string.
1222 * @param lhs A regular expression submatch.
1223 * @param rhs A string.
1224 * @returns true if @a lhs does not precede @a rhs, false otherwise.
1226 template<typename _Bi_iter>
1227 inline bool
1228 operator>=(const sub_match<_Bi_iter>& __lhs,
1229 typename iterator_traits<_Bi_iter>::value_type const* __rhs)
1230 { return __lhs.str() >= __rhs; }
1233 * @brief Tests the ordering of a regular expression submatch and a string.
1234 * @param lhs A regular expression submatch.
1235 * @param rhs A string.
1236 * @returns true if @a lhs does not succeed @a rhs, false otherwise.
1238 template<typename _Bi_iter>
1239 inline bool
1240 operator<=(const sub_match<_Bi_iter>& __lhs,
1241 typename iterator_traits<_Bi_iter>::value_type const* __rhs)
1242 { return __lhs.str() <= __rhs; }
1245 * @brief Tests the equivalence of a string and a regular expression
1246 * submatch.
1247 * @param lhs A string.
1248 * @param rhs A regular expression submatch.
1249 * @returns true if @a lhs is equivalent to @a rhs, false otherwise.
1251 template<typename _Bi_iter>
1252 inline bool
1253 operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
1254 const sub_match<_Bi_iter>& __rhs)
1255 { return __lhs == __rhs.str(); }
1258 * @brief Tests the inequivalence of a string and a regular expression
1259 * submatch.
1260 * @param lhs A string.
1261 * @param rhs A regular expression submatch.
1262 * @returns true if @a lhs is not equivalent to @a rhs, false otherwise.
1264 template<typename _Bi_iter>
1265 inline bool
1266 operator!=(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
1267 const sub_match<_Bi_iter>& __rhs)
1268 { return __lhs != __rhs.str(); }
1271 * @brief Tests the ordering of a string and a regular expression submatch.
1272 * @param lhs A string.
1273 * @param rhs A regular expression submatch.
1274 * @returns true if @a lhs precedes @a rhs, false otherwise.
1276 template<typename _Bi_iter>
1277 inline bool
1278 operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
1279 const sub_match<_Bi_iter>& __rhs)
1280 { return __lhs < __rhs.str(); }
1283 * @brief Tests the ordering of a string and a regular expression submatch.
1284 * @param lhs A string.
1285 * @param rhs A regular expression submatch.
1286 * @returns true if @a lhs succeeds @a rhs, false otherwise.
1288 template<typename _Bi_iter>
1289 inline bool
1290 operator>(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
1291 const sub_match<_Bi_iter>& __rhs)
1292 { return __lhs > __rhs.str(); }
1295 * @brief Tests the ordering of a string and a regular expression submatch.
1296 * @param lhs A string.
1297 * @param rhs A regular expression submatch.
1298 * @returns true if @a lhs does not precede @a rhs, false otherwise.
1300 template<typename _Bi_iter>
1301 inline bool
1302 operator>=(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
1303 const sub_match<_Bi_iter>& __rhs)
1304 { return __lhs >= __rhs.str(); }
1307 * @brief Tests the ordering of a string and a regular expression submatch.
1308 * @param lhs A string.
1309 * @param rhs A regular expression submatch.
1310 * @returns true if @a lhs does not succeed @a rhs, false otherwise.
1312 template<typename _Bi_iter>
1313 inline bool
1314 operator<=(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
1315 const sub_match<_Bi_iter>& __rhs)
1316 { return __lhs <= __rhs.str(); }
1319 * @brief Tests the equivalence of a regular expression submatch and a
1320 * string.
1321 * @param lhs A regular expression submatch.
1322 * @param rhs A const string reference.
1323 * @returns true if @a lhs is equivalent to @a rhs, false otherwise.
1325 template<typename _Bi_iter>
1326 inline bool
1327 operator==(const sub_match<_Bi_iter>& __lhs,
1328 typename iterator_traits<_Bi_iter>::value_type const& __rhs)
1329 { return __lhs.str() == __rhs; }
1332 * @brief Tests the inequivalence of a regular expression submatch and a
1333 * string.
1334 * @param lhs A regular expression submatch.
1335 * @param rhs A const string reference.
1336 * @returns true if @a lhs is not equivalent to @a rhs, false otherwise.
1338 template<typename _Bi_iter>
1339 inline bool
1340 operator!=(const sub_match<_Bi_iter>& __lhs,
1341 typename iterator_traits<_Bi_iter>::value_type const& __rhs)
1342 { return __lhs.str() != __rhs; }
1345 * @brief Tests the ordering of a regular expression submatch and a string.
1346 * @param lhs A regular expression submatch.
1347 * @param rhs A const string reference.
1348 * @returns true if @a lhs precedes @a rhs, false otherwise.
1350 template<typename _Bi_iter>
1351 inline bool
1352 operator<(const sub_match<_Bi_iter>& __lhs,
1353 typename iterator_traits<_Bi_iter>::value_type const& __rhs)
1354 { return __lhs.str() < __rhs; }
1357 * @brief Tests the ordering of a regular expression submatch and a string.
1358 * @param lhs A regular expression submatch.
1359 * @param rhs A const string reference.
1360 * @returns true if @a lhs succeeds @a rhs, false otherwise.
1362 template<typename _Bi_iter>
1363 inline bool
1364 operator>(const sub_match<_Bi_iter>& __lhs,
1365 typename iterator_traits<_Bi_iter>::value_type const& __rhs)
1366 { return __lhs.str() > __rhs; }
1369 * @brief Tests the ordering of a regular expression submatch and a string.
1370 * @param lhs A regular expression submatch.
1371 * @param rhs A const string reference.
1372 * @returns true if @a lhs does not precede @a rhs, false otherwise.
1374 template<typename _Bi_iter>
1375 inline bool
1376 operator>=(const sub_match<_Bi_iter>& __lhs,
1377 typename iterator_traits<_Bi_iter>::value_type const& __rhs)
1378 { return __lhs.str() >= __rhs; }
1381 * @brief Tests the ordering of a regular expression submatch and a string.
1382 * @param lhs A regular expression submatch.
1383 * @param rhs A const string reference.
1384 * @returns true if @a lhs does not succeed @a rhs, false otherwise.
1386 template<typename _Bi_iter>
1387 inline bool
1388 operator<=(const sub_match<_Bi_iter>& __lhs,
1389 typename iterator_traits<_Bi_iter>::value_type const& __rhs)
1390 { return __lhs.str() <= __rhs; }
1393 * @brief Inserts a matched string into an output stream.
1395 * @param os The output stream.
1396 * @param m A submatch string.
1398 * @returns the output stream with the submatch string inserted.
1400 template<typename _Ch_type, typename _Ch_traits, typename _Bi_iter>
1401 inline
1402 basic_ostream<_Ch_type, _Ch_traits>&
1403 operator<<(basic_ostream<_Ch_type, _Ch_traits>& __os,
1404 const sub_match<_Bi_iter>& __m)
1405 { return __os << __m.str(); }
1407 // [7.10] Class template match_results
1410 * Special sub_match object representing an unmatched sub-expression.
1412 template<typename _Bi_iter>
1413 inline const sub_match<_Bi_iter>&
1414 __unmatched_sub()
1416 static const sub_match<_Bi_iter> __unmatched = sub_match<_Bi_iter>();
1417 return __unmatched;
1421 * @brief The results of a match or search operation.
1423 * A collection of character sequences representing the result of a regular
1424 * expression match. Storage for the collection is allocated and freed as
1425 * necessary by the member functions of class template match_results.
1427 * This class satisfies the Sequence requirements, with the exception that
1428 * only the operations defined for a const-qualified Sequence are supported.
1430 * The sub_match object stored at index 0 represents sub-expression 0, i.e.
1431 * the whole match. In this case the %sub_match member matched is always true.
1432 * The sub_match object stored at index n denotes what matched the marked
1433 * sub-expression n within the matched expression. If the sub-expression n
1434 * participated in a regular expression match then the %sub_match member
1435 * matched evaluates to true, and members first and second denote the range
1436 * of characters [first, second) which formed that match. Otherwise matched
1437 * is false, and members first and second point to the end of the sequence
1438 * that was searched.
1440 * @nosubgrouping
1442 template<typename _Bi_iter,
1443 typename _Allocator = allocator<sub_match<_Bi_iter> > >
1444 class match_results
1445 : private std::vector<std::sub_match<_Bi_iter>, _Allocator>
1447 private:
1449 * The vector base is empty if this does not represent a successful match.
1450 * Otherwise it contains n+3 elements where n is the number of marked
1451 * sub-expressions:
1452 * [0] entire match
1453 * [1] 1st marked subexpression
1454 * ...
1455 * [n] nth marked subexpression
1456 * [n+1] prefix
1457 * [n+2] suffix
1459 typedef std::vector<std::sub_match<_Bi_iter>, _Allocator>
1460 _Base_type;
1462 public:
1464 * @name 10.? Public Types
1466 //@{
1467 typedef sub_match<_Bi_iter> value_type;
1468 typedef const value_type& const_reference;
1469 typedef const_reference reference;
1470 typedef typename _Base_type::const_iterator const_iterator;
1471 typedef const_iterator iterator;
1472 typedef typename std::iterator_traits<_Bi_iter>::difference_type
1473 difference_type;
1474 /* TODO: needs allocator_traits */
1475 typedef typename _Allocator::size_type size_type;
1476 typedef _Allocator allocator_type;
1477 typedef typename std::iterator_traits<_Bi_iter>::value_type
1478 char_type;
1479 typedef std::basic_string<char_type> string_type;
1480 //@}
1482 public:
1484 * @name 10.1 Construction, Copying, and Destruction
1486 //@{
1489 * @brief Constructs a default %match_results container.
1490 * @post size() returns 0 and str() returns an empty string.
1492 explicit
1493 match_results(const _Allocator& __a = _Allocator())
1494 : _Base_type(__a)
1498 * @brief Copy constructs a %match_results.
1500 match_results(const match_results& __rhs)
1501 : _Base_type(__rhs)
1505 * @brief Assigns rhs to *this.
1507 match_results&
1508 operator=(const match_results __rhs)
1510 match_results(__rhs).swap(*this);
1511 return *this;
1515 * @brief Destroys a %match_results object.
1517 ~match_results()
1520 //@}
1523 * @name 10.2 Size
1525 //@{
1528 * @brief Gets the number of matches and submatches.
1530 * The number of matches for a given regular expression will be either 0
1531 * if there was no match or mark_count() + 1 if a match was successful.
1532 * Some matches may be empty.
1534 * @returns the number of matches found.
1536 size_type
1537 size() const
1539 size_type __size = _Base_type::size();
1540 return (__size && _Base_type::operator[](0).matched) ? __size - 2 : 0;
1543 size_type
1544 max_size() const
1545 { return _Base_type::max_size(); }
1548 * @brief Indicates if the %match_results contains no results.
1549 * @retval true The %match_results object is empty.
1550 * @retval false The %match_results object is not empty.
1552 bool
1553 empty() const
1554 { return _Base_type::empty(); }
1556 //@}
1559 * @name 10.3 Element Access
1561 //@{
1564 * @brief Gets the length of the indicated submatch.
1565 * @param sub indicates the submatch.
1567 * This function returns the length of the indicated submatch, or the
1568 * length of the entire match if @p sub is zero (the default).
1570 difference_type
1571 length(size_type __sub = 0) const
1572 { return this[__sub].length(); }
1575 * @brief Gets the offset of the beginning of the indicated submatch.
1576 * @param sub indicates the submatch.
1578 * This function returns the offset from the beginning of the target
1579 * sequence to the beginning of the submatch, unless the value of @p sub
1580 * is zero (the default), in which case this function returns the offset
1581 * from the beginning of the target sequence to the beginning of the
1582 * match.
1584 * Returns -1 if @p sub is out of range.
1586 difference_type
1587 position(size_type __sub = 0) const
1589 return __sub < size() ? std::distance(this->prefix().first,
1590 (*this)[__sub].first) : -1;
1594 * @brief Gets the match or submatch converted to a string type.
1595 * @param sub indicates the submatch.
1597 * This function gets the submatch (or match, if @p sub is zero) extracted
1598 * from the target range and converted to the associated string type.
1600 string_type
1601 str(size_type __sub = 0) const
1602 { return (*this)[__sub].str(); }
1605 * @brief Gets a %sub_match reference for the match or submatch.
1606 * @param sub indicates the submatch.
1608 * This function gets a reference to the indicated submatch, or the entire
1609 * match if @p sub is zero.
1611 * If @p sub >= size() then this function returns a %sub_match with a
1612 * special value indicating no submatch.
1614 const_reference
1615 operator[](size_type __sub) const
1617 return __sub < size()
1618 ? _Base_type::operator[](__sub)
1619 : __unmatched_sub<_Bi_iter>();
1623 * @brief Gets a %sub_match representing the match prefix.
1625 * This function gets a reference to a %sub_match object representing the
1626 * part of the target range between the start of the target range and the
1627 * start of the match.
1629 const_reference
1630 prefix() const
1632 return !empty()
1633 ? _Base_type::operator[](_Base_type::size() - 2)
1634 : __unmatched_sub<_Bi_iter>();
1638 * @brief Gets a %sub_match representing the match suffix.
1640 * This function gets a reference to a %sub_match object representing the
1641 * part of the target range between the end of the match and the end of
1642 * the target range.
1644 const_reference
1645 suffix() const
1647 return !empty()
1648 ? _Base_type::operator[](_Base_type::size() - 1)
1649 : __unmatched_sub<_Bi_iter>();
1653 * @brief Gets an iterator to the start of the %sub_match collection.
1655 const_iterator
1656 begin() const
1657 { return _Base_type::begin(); }
1660 * @brief Gets an iterator to the start of the %sub_match collection.
1662 const_iterator
1663 cbegin() const
1664 { return _Base_type::cbegin(); }
1667 * @brief Gets an iterator to one-past-the-end of the collection.
1669 const_iterator
1670 end() const
1672 return !empty()
1673 ? _Base_type::end() - 2
1674 : _Base_type::end();
1678 * @brief Gets an iterator to one-past-the-end of the collection.
1680 const_iterator
1681 cend() const
1683 return !empty()
1684 ? _Base_type::cend() - 2
1685 : _Base_type::cend();
1688 //@}
1691 * @name 10.4 Formatting
1693 * These functions perform formatted substitution of the matched character
1694 * sequences into their target. The format specifiers and escape sequences
1695 * accepted by these functions are determined by their @p flags parameter
1696 * as documented above.
1698 //@{
1701 * @todo Implement this function.
1703 template<typename _Out_iter>
1704 _Out_iter
1705 format(_Out_iter __out, const string_type& __fmt,
1706 regex_constants::match_flag_type __flags
1707 = regex_constants::format_default) const
1708 { return __out; }
1711 * @todo Implement this function.
1713 string_type
1714 format(const string_type& __fmt,
1715 regex_constants::match_flag_type __flags
1716 = regex_constants::format_default) const;
1718 //@}
1721 * @name 10.5 Allocator
1723 //@{
1726 * @brief Gets a copy of the allocator.
1728 allocator_type
1729 get_allocator() const
1730 { return _Base_type::get_allocator(); }
1732 //@}
1735 * @name 10.6 Swap
1737 //@{
1740 * @brief Swaps the contents of two match_results.
1742 void
1743 swap(match_results& __that)
1744 { _Base_type::swap(__that); }
1745 //@}
1747 private:
1748 friend class __regex::_SpecializedResults<_Bi_iter, _Allocator>;
1751 typedef match_results<const char*> cmatch;
1752 typedef match_results<string::const_iterator> smatch;
1753 #ifdef _GLIBCXX_USE_WCHAR_T
1754 typedef match_results<const wchar_t*> wcmatch;
1755 typedef match_results<wstring::const_iterator> wsmatch;
1756 #endif
1758 // match_results comparisons
1760 * @brief Compares two match_results for equality.
1761 * @returns true if the two objects refer to the same match,
1762 * false otherwise.
1763 * @todo Implement this function.
1765 template<typename _Bi_iter, typename _Allocator>
1766 inline bool
1767 operator==(const match_results<_Bi_iter, _Allocator>& __m1,
1768 const match_results<_Bi_iter, _Allocator>& __m2);
1771 * @brief Compares two match_results for inequality.
1772 * @returns true if the two objects do not refer to the same match,
1773 * false otherwise.
1775 template<typename _Bi_iter, class _Allocator>
1776 inline bool
1777 operator!=(const match_results<_Bi_iter, _Allocator>& __m1,
1778 const match_results<_Bi_iter, _Allocator>& __m2)
1779 { return !(__m1 == __m2); }
1781 // [7.10.6] match_results swap
1783 * @brief Swaps two match results.
1784 * @param lhs A match result.
1785 * @param rhs A match result.
1787 * The contents of the two match_results objects are swapped.
1789 template<typename _Bi_iter, typename _Allocator>
1790 inline void
1791 swap(match_results<_Bi_iter, _Allocator>& __lhs,
1792 match_results<_Bi_iter, _Allocator>& __rhs)
1793 { __lhs.swap(__rhs); }
1795 // [7.11.2] Function template regex_match
1797 * @name Matching, Searching, and Replacing
1799 //@{
1802 * @brief Determines if there is a match between the regular expression @p e
1803 * and all of the character sequence [first, last).
1805 * @param s Start of the character sequence to match.
1806 * @param e One-past-the-end of the character sequence to match.
1807 * @param m The match results.
1808 * @param re The regular expression.
1809 * @param flags Controls how the regular expression is matched.
1811 * @retval true A match exists.
1812 * @retval false Otherwise.
1814 * @throws an exception of type regex_error.
1816 * @todo Implement this function.
1818 template<typename _Bi_iter, typename _Allocator,
1819 typename _Ch_type, typename _Rx_traits>
1820 bool
1821 regex_match(_Bi_iter __s,
1822 _Bi_iter __e,
1823 match_results<_Bi_iter, _Allocator>& __m,
1824 const basic_regex<_Ch_type, _Rx_traits>& __re,
1825 regex_constants::match_flag_type __flags
1826 = regex_constants::match_default)
1828 __regex::_AutomatonPtr __a = __re._M_get_automaton();
1829 __regex::_Automaton::_SizeT __sz = __a->_M_sub_count();
1830 __regex::_SpecializedCursor<_Bi_iter> __cs(__s, __e);
1831 __regex::_SpecializedResults<_Bi_iter, _Allocator> __r(__sz, __cs, __m);
1832 __regex::_Grep_matcher __matcher(__cs, __r, __a, __flags);
1833 return __m[0].matched;
1837 * @brief Indicates if there is a match between the regular expression @p e
1838 * and all of the character sequence [first, last).
1840 * @param first Beginning of the character sequence to match.
1841 * @param last One-past-the-end of the character sequence to match.
1842 * @param re The regular expression.
1843 * @param flags Controls how the regular expression is matched.
1845 * @retval true A match exists.
1846 * @retval false Otherwise.
1848 * @throws an exception of type regex_error.
1850 template<typename _Bi_iter, typename _Ch_type, typename _Rx_traits>
1851 bool
1852 regex_match(_Bi_iter __first, _Bi_iter __last,
1853 const basic_regex<_Ch_type, _Rx_traits>& __re,
1854 regex_constants::match_flag_type __flags
1855 = regex_constants::match_default)
1857 match_results<_Bi_iter> __what;
1858 return regex_match(__first, __last, __what, __re, __flags);
1862 * @brief Determines if there is a match between the regular expression @p e
1863 * and a C-style null-terminated string.
1865 * @param s The C-style null-terminated string to match.
1866 * @param m The match results.
1867 * @param re The regular expression.
1868 * @param f Controls how the regular expression is matched.
1870 * @retval true A match exists.
1871 * @retval false Otherwise.
1873 * @throws an exception of type regex_error.
1875 template<typename _Ch_type, typename _Allocator, typename _Rx_traits>
1876 inline bool
1877 regex_match(const _Ch_type* __s,
1878 match_results<const _Ch_type*, _Allocator>& __m,
1879 const basic_regex<_Ch_type, _Rx_traits>& __re,
1880 regex_constants::match_flag_type __f
1881 = regex_constants::match_default)
1882 { return regex_match(__s, __s + _Rx_traits::length(__s), __m, __re, __f); }
1885 * @brief Determines if there is a match between the regular expression @p e
1886 * and a string.
1888 * @param s The string to match.
1889 * @param m The match results.
1890 * @param re The regular expression.
1891 * @param flags Controls how the regular expression is matched.
1893 * @retval true A match exists.
1894 * @retval false Otherwise.
1896 * @throws an exception of type regex_error.
1898 template<typename _Ch_traits, typename _Ch_alloc,
1899 typename _Allocator, typename _Ch_type, typename _Rx_traits>
1900 inline bool
1901 regex_match(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s,
1902 match_results<typename basic_string<_Ch_type,
1903 _Ch_traits, _Ch_alloc>::const_iterator, _Allocator>& __m,
1904 const basic_regex<_Ch_type, _Rx_traits>& __re,
1905 regex_constants::match_flag_type __flags
1906 = regex_constants::match_default)
1907 { return regex_match(__s.begin(), __s.end(), __m, __re, __flags); }
1910 * @brief Indicates if there is a match between the regular expression @p e
1911 * and a C-style null-terminated string.
1913 * @param s The C-style null-terminated string to match.
1914 * @param re The regular expression.
1915 * @param f Controls how the regular expression is matched.
1917 * @retval true A match exists.
1918 * @retval false Otherwise.
1920 * @throws an exception of type regex_error.
1922 template<typename _Ch_type, class _Rx_traits>
1923 inline bool
1924 regex_match(const _Ch_type* __s,
1925 const basic_regex<_Ch_type, _Rx_traits>& __re,
1926 regex_constants::match_flag_type __f
1927 = regex_constants::match_default)
1928 { return regex_match(__s, __s + _Rx_traits::length(__s), __re, __f); }
1931 * @brief Indicates if there is a match between the regular expression @p e
1932 * and a string.
1934 * @param s [IN] The string to match.
1935 * @param re [IN] The regular expression.
1936 * @param flags [IN] Controls how the regular expression is matched.
1938 * @retval true A match exists.
1939 * @retval false Otherwise.
1941 * @throws an exception of type regex_error.
1943 template<typename _Ch_traits, typename _Str_allocator,
1944 typename _Ch_type, typename _Rx_traits>
1945 inline bool
1946 regex_match(const basic_string<_Ch_type, _Ch_traits, _Str_allocator>& __s,
1947 const basic_regex<_Ch_type, _Rx_traits>& __re,
1948 regex_constants::match_flag_type __flags
1949 = regex_constants::match_default)
1950 { return regex_match(__s.begin(), __s.end(), __re, __flags); }
1952 // [7.11.3] Function template regex_search
1954 * Searches for a regular expression within a range.
1955 * @param first [IN] The start of the string to search.
1956 * @param last [IN] One-past-the-end of the string to search.
1957 * @param m [OUT] The match results.
1958 * @param re [IN] The regular expression to search for.
1959 * @param flags [IN] Search policy flags.
1960 * @retval true A match was found within the string.
1961 * @retval false No match was found within the string, the content of %m is
1962 * undefined.
1964 * @throws an exception of type regex_error.
1966 * @todo Implement this function.
1968 template<typename _Bi_iter, typename _Allocator,
1969 typename _Ch_type, typename _Rx_traits>
1970 inline bool
1971 regex_search(_Bi_iter __first, _Bi_iter __last,
1972 match_results<_Bi_iter, _Allocator>& __m,
1973 const basic_regex<_Ch_type, _Rx_traits>& __re,
1974 regex_constants::match_flag_type __flags
1975 = regex_constants::match_default)
1976 { return false; }
1979 * Searches for a regular expression within a range.
1980 * @param first [IN] The start of the string to search.
1981 * @param last [IN] One-past-the-end of the string to search.
1982 * @param re [IN] The regular expression to search for.
1983 * @param flags [IN] Search policy flags.
1984 * @retval true A match was found within the string.
1985 * @retval false No match was found within the string.
1986 * @doctodo
1988 * @throws an exception of type regex_error.
1990 template<typename _Bi_iter, typename _Ch_type, typename _Rx_traits>
1991 inline bool
1992 regex_search(_Bi_iter __first, _Bi_iter __last,
1993 const basic_regex<_Ch_type, _Rx_traits>& __re,
1994 regex_constants::match_flag_type __flags
1995 = regex_constants::match_default)
1997 match_results<_Bi_iter> __what;
1998 return regex_search(__first, __last, __what, __re, __flags);
2002 * @brief Searches for a regular expression within a C-string.
2003 * @param s [IN] A C-string to search for the regex.
2004 * @param m [OUT] The set of regex matches.
2005 * @param e [IN] The regex to search for in @p s.
2006 * @param f [IN] The search flags.
2007 * @retval true A match was found within the string.
2008 * @retval false No match was found within the string, the content of %m is
2009 * undefined.
2010 * @doctodo
2012 * @throws an exception of type regex_error.
2014 template<typename _Ch_type, class _Allocator, class _Rx_traits>
2015 inline bool
2016 regex_search(const _Ch_type* __s,
2017 match_results<const _Ch_type*, _Allocator>& __m,
2018 const basic_regex<_Ch_type, _Rx_traits>& __e,
2019 regex_constants::match_flag_type __f
2020 = regex_constants::match_default)
2021 { return regex_search(__s, __s + _Rx_traits::length(__s), __m, __e, __f); }
2024 * @brief Searches for a regular expression within a C-string.
2025 * @param s [IN] The C-string to search.
2026 * @param e [IN] The regular expression to search for.
2027 * @param f [IN] Search policy flags.
2028 * @retval true A match was found within the string.
2029 * @retval false No match was found within the string.
2030 * @doctodo
2032 * @throws an exception of type regex_error.
2034 template<typename _Ch_type, typename _Rx_traits>
2035 inline bool
2036 regex_search(const _Ch_type* __s,
2037 const basic_regex<_Ch_type, _Rx_traits>& __e,
2038 regex_constants::match_flag_type __f
2039 = regex_constants::match_default)
2040 { return regex_search(__s, __s + _Rx_traits::length(__s), __e, __f); }
2043 * @brief Searches for a regular expression within a string.
2044 * @param s [IN] The string to search.
2045 * @param e [IN] The regular expression to search for.
2046 * @param flags [IN] Search policy flags.
2047 * @retval true A match was found within the string.
2048 * @retval false No match was found within the string.
2049 * @doctodo
2051 * @throws an exception of type regex_error.
2053 template<typename _Ch_traits, typename _String_allocator,
2054 typename _Ch_type, typename _Rx_traits>
2055 inline bool
2056 regex_search(const basic_string<_Ch_type, _Ch_traits,
2057 _String_allocator>& __s,
2058 const basic_regex<_Ch_type, _Rx_traits>& __e,
2059 regex_constants::match_flag_type __flags
2060 = regex_constants::match_default)
2061 { return regex_search(__s.begin(), __s.end(), __e, __flags); }
2064 * @brief Searches for a regular expression within a string.
2065 * @param s [IN] A C++ string to search for the regex.
2066 * @param m [OUT] The set of regex matches.
2067 * @param e [IN] The regex to search for in @p s.
2068 * @param f [IN] The search flags.
2069 * @retval true A match was found within the string.
2070 * @retval false No match was found within the string, the content of %m is
2071 * undefined.
2073 * @throws an exception of type regex_error.
2075 template<typename _Ch_traits, typename _Ch_alloc,
2076 typename _Allocator, typename _Ch_type,
2077 typename _Rx_traits>
2078 inline bool
2079 regex_search(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s,
2080 match_results<typename basic_string<_Ch_type,
2081 _Ch_traits, _Ch_alloc>::const_iterator, _Allocator>& __m,
2082 const basic_regex<_Ch_type, _Rx_traits>& __e,
2083 regex_constants::match_flag_type __f
2084 = regex_constants::match_default)
2085 { return regex_search(__s.begin(), __s.end(), __m, __e, __f); }
2087 // std [28.11.4] Function template regex_replace
2089 * @doctodo
2090 * @param out
2091 * @param first
2092 * @param last
2093 * @param e
2094 * @param fmt
2095 * @param flags
2097 * @returns out
2098 * @throws an exception of type regex_error.
2100 * @todo Implement this function.
2102 template<typename _Out_iter, typename _Bi_iter,
2103 typename _Rx_traits, typename _Ch_type>
2104 inline _Out_iter
2105 regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
2106 const basic_regex<_Ch_type, _Rx_traits>& __e,
2107 const basic_string<_Ch_type>& __fmt,
2108 regex_constants::match_flag_type __flags
2109 = regex_constants::match_default)
2110 { return __out; }
2113 * @doctodo
2114 * @param s
2115 * @param e
2116 * @param fmt
2117 * @param flags
2119 * @returns a copy of string @p s with replacements.
2121 * @throws an exception of type regex_error.
2123 template<typename _Rx_traits, typename _Ch_type>
2124 inline basic_string<_Ch_type>
2125 regex_replace(const basic_string<_Ch_type>& __s,
2126 const basic_regex<_Ch_type, _Rx_traits>& __e,
2127 const basic_string<_Ch_type>& __fmt,
2128 regex_constants::match_flag_type __flags
2129 = regex_constants::match_default)
2131 std::string __result;
2132 regex_replace(std::back_inserter(__result),
2133 __s.begin(), __s.end(), __e, __fmt, __flags);
2134 return __result;
2137 //@}
2139 // std [28.12] Class template regex_iterator
2141 * An iterator adaptor that will provide repeated calls of regex_search over
2142 * a range until no more matches remain.
2144 template<typename _Bi_iter,
2145 typename _Ch_type = typename iterator_traits<_Bi_iter>::value_type,
2146 typename _Rx_traits = regex_traits<_Ch_type> >
2147 class regex_iterator
2149 public:
2150 typedef basic_regex<_Ch_type, _Rx_traits> regex_type;
2151 typedef match_results<_Bi_iter> value_type;
2152 typedef std::ptrdiff_t difference_type;
2153 typedef const value_type* pointer;
2154 typedef const value_type& reference;
2155 typedef std::forward_iterator_tag iterator_category;
2157 public:
2159 * @brief Provides a singular iterator, useful for indicating
2160 * one-past-the-end of a range.
2161 * @todo Implement this function.
2162 * @doctodo
2164 regex_iterator();
2167 * Constructs a %regex_iterator...
2168 * @param a [IN] The start of a text range to search.
2169 * @param b [IN] One-past-the-end of the text range to search.
2170 * @param re [IN] The regular expression to match.
2171 * @param m [IN] Policy flags for match rules.
2172 * @todo Implement this function.
2173 * @doctodo
2175 regex_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type& __re,
2176 regex_constants::match_flag_type __m
2177 = regex_constants::match_default);
2180 * Copy constructs a %regex_iterator.
2181 * @todo Implement this function.
2182 * @doctodo
2184 regex_iterator(const regex_iterator& __rhs);
2187 * @todo Implement this function.
2188 * @doctodo
2190 regex_iterator&
2191 operator=(const regex_iterator& __rhs);
2194 * @todo Implement this function.
2195 * @doctodo
2197 bool
2198 operator==(const regex_iterator& __rhs);
2201 * @todo Implement this function.
2202 * @doctodo
2204 bool
2205 operator!=(const regex_iterator& __rhs);
2208 * @todo Implement this function.
2209 * @doctodo
2211 const value_type&
2212 operator*();
2215 * @todo Implement this function.
2216 * @doctodo
2218 const value_type*
2219 operator->();
2222 * @todo Implement this function.
2223 * @doctodo
2225 regex_iterator&
2226 operator++();
2229 * @todo Implement this function.
2230 * @doctodo
2232 regex_iterator
2233 operator++(int);
2235 private:
2236 // these members are shown for exposition only:
2237 _Bi_iter begin;
2238 _Bi_iter end;
2239 const regex_type* pregex;
2240 regex_constants::match_flag_type flags;
2241 match_results<_Bi_iter> match;
2244 typedef regex_iterator<const char*> cregex_iterator;
2245 typedef regex_iterator<string::const_iterator> sregex_iterator;
2246 #ifdef _GLIBCXX_USE_WCHAR_T
2247 typedef regex_iterator<const wchar_t*> wcregex_iterator;
2248 typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
2249 #endif
2251 // [7.12.2] Class template regex_token_iterator
2253 * Iterates over submatches in a range (or @a splits a text string).
2255 * The purpose of this iterator is to enumerate all, or all specified,
2256 * matches of a regular expression within a text range. The dereferenced
2257 * value of an iterator of this class is a std::sub_match object.
2259 template<typename _Bi_iter,
2260 typename _Ch_type = typename iterator_traits<_Bi_iter>::value_type,
2261 typename _Rx_traits = regex_traits<_Ch_type> >
2262 class regex_token_iterator
2264 public:
2265 typedef basic_regex<_Ch_type, _Rx_traits> regex_type;
2266 typedef sub_match<_Bi_iter> value_type;
2267 typedef std::ptrdiff_t difference_type;
2268 typedef const value_type* pointer;
2269 typedef const value_type& reference;
2270 typedef std::forward_iterator_tag iterator_category;
2272 public:
2274 * @brief Default constructs a %regex_token_iterator.
2275 * @todo Implement this function.
2277 * A default-constructed %regex_token_iterator is a singular iterator
2278 * that will compare equal to the one-past-the-end value for any
2279 * iterator of the same type.
2281 regex_token_iterator();
2284 * Constructs a %regex_token_iterator...
2285 * @param a [IN] The start of the text to search.
2286 * @param b [IN] One-past-the-end of the text to search.
2287 * @param re [IN] The regular expression to search for.
2288 * @param submatch [IN] Which submatch to return. There are some
2289 * special values for this parameter:
2290 * - -1 each enumerated subexpression does NOT
2291 * match the regular expression (aka field
2292 * splitting)
2293 * - 0 the entire string matching the
2294 * subexpression is returned for each match
2295 * within the text.
2296 * - >0 enumerates only the indicated
2297 * subexpression from a match within the text.
2298 * @param m [IN] Policy flags for match rules.
2300 * @todo Implement this function.
2301 * @doctodo
2303 regex_token_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type& __re,
2304 int __submatch = 0,
2305 regex_constants::match_flag_type __m
2306 = regex_constants::match_default);
2309 * Constructs a %regex_token_iterator...
2310 * @param a [IN] The start of the text to search.
2311 * @param b [IN] One-past-the-end of the text to search.
2312 * @param re [IN] The regular expression to search for.
2313 * @param submatches [IN] A list of subexpressions to return for each
2314 * regular expression match within the text.
2315 * @param m [IN] Policy flags for match rules.
2317 * @todo Implement this function.
2318 * @doctodo
2320 regex_token_iterator(_Bi_iter __a, _Bi_iter __b,
2321 const regex_type& __re,
2322 const std::vector<int>& __submatches,
2323 regex_constants::match_flag_type __m
2324 = regex_constants::match_default);
2327 * Constructs a %regex_token_iterator...
2328 * @param a [IN] The start of the text to search.
2329 * @param b [IN] One-past-the-end of the text to search.
2330 * @param re [IN] The regular expression to search for.
2331 * @param submatches [IN] A list of subexpressions to return for each
2332 * regular expression match within the text.
2333 * @param m [IN] Policy flags for match rules.
2335 * @todo Implement this function.
2336 * @doctodo
2338 template<std::size_t _Nm>
2339 regex_token_iterator(_Bi_iter __a, _Bi_iter __b,
2340 const regex_type& __re,
2341 const int (&__submatches)[_Nm],
2342 regex_constants::match_flag_type __m
2343 = regex_constants::match_default);
2346 * @brief Copy constructs a %regex_token_iterator.
2347 * @param rhs [IN] A %regex_token_iterator to copy.
2348 * @todo Implement this function.
2350 regex_token_iterator(const regex_token_iterator& __rhs);
2353 * @brief Assigns a %regex_token_iterator to another.
2354 * @param rhs [IN] A %regex_token_iterator to copy.
2355 * @todo Implement this function.
2357 regex_token_iterator&
2358 operator=(const regex_token_iterator& __rhs);
2361 * @brief Compares a %regex_token_iterator to another for equality.
2362 * @todo Implement this function.
2364 bool
2365 operator==(const regex_token_iterator& __rhs);
2368 * @brief Compares a %regex_token_iterator to another for inequality.
2369 * @todo Implement this function.
2371 bool
2372 operator!=(const regex_token_iterator& __rhs);
2375 * @brief Dereferences a %regex_token_iterator.
2376 * @todo Implement this function.
2378 const value_type&
2379 operator*();
2382 * @brief Selects a %regex_token_iterator member.
2383 * @todo Implement this function.
2385 const value_type*
2386 operator->();
2389 * @brief Increments a %regex_token_iterator.
2390 * @todo Implement this function.
2392 regex_token_iterator&
2393 operator++();
2396 * @brief Postincrements a %regex_token_iterator.
2397 * @todo Implement this function.
2399 regex_token_iterator
2400 operator++(int);
2402 private: // data members for exposition only:
2403 typedef regex_iterator<_Bi_iter, _Ch_type, _Rx_traits> position_iterator;
2405 position_iterator __position;
2406 const value_type* __result;
2407 value_type __suffix;
2408 std::size_t __n;
2409 std::vector<int> __subs;
2412 /** @brief Token iterator for C-style NULL-terminated strings. */
2413 typedef regex_token_iterator<const char*> cregex_token_iterator;
2414 /** @brief Token iterator for standard strings. */
2415 typedef regex_token_iterator<string::const_iterator> sregex_token_iterator;
2416 #ifdef _GLIBCXX_USE_WCHAR_T
2417 /** @brief Token iterator for C-style NULL-terminated wide strings. */
2418 typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
2419 /** @brief Token iterator for standard wide-character strings. */
2420 typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
2421 #endif
2423 //@} // group regex
2424 _GLIBCXX_END_NAMESPACE