# tr1_impl/regex

Go to the documentation of this file.

    00001 // class template regex -*- C++ -*-
    00002
    00003 // Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
    00004 //
    00005 // This file is part of the GNU ISO C++ Library.  This library is free
    00006 // software; you can redistribute it and/or modify it under the
    00007 // terms of the GNU General Public License as published by the
    00008 // Free Software Foundation; either version 3, or (at your option)
    00009 // any later version.
    00010
    00011 // This library is distributed in the hope that it will be useful,
    00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00014 // GNU General Public License for more details.
    00015
    00016 // Under Section 7 of GPL version 3, you are granted additional
    00017 // permissions described in the GCC Runtime Library Exception, version
    00018 // 3.1, as published by the Free Software Foundation.
    00019
    00020 // You should have received a copy of the GNU General Public License and
    00021 // a copy of the GCC Runtime Library Exception along with this program;
    00022 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    00023 // <http://www.gnu.org/licenses/>.
    00024
    00025 /**
    00026  * @file tr1_impl/regex
    00027  * @brief The common implementation file for tr1 and std regular expressions.
    00028  *
    00029  *  This is an internal header file, included by other library headers.
    00030  *  You should not attempt to use it directly.
    00031  */
    00032
    00033 namespace std
    00034 {
    00035 _GLIBCXX_BEGIN_NAMESPACE_TR1
    00036
    00037 /**
    00038  * @defgroup tr1_regex Regular Expressions
    00039  * A facility for performing regular expression pattern matching.
    00040  */
    00041  //@{
    00042
    00043 /** @namespace std::regex_constants
    00044  *  @brief ISO C++ 0x entities sub namespace for regex.
    00045  */
    00046 namespace regex_constants
    00047 {
    00048   /**
    00049    * @name 5.1 Regular Expression Syntax Options
    00050    */
    00051   //@{
    00052   enum __syntax_option
    00053     {
    00054       _S_icase,
    00055       _S_nosubs,
    00056       _S_optimize,
    00057       _S_collate,
    00058       _S_ECMAScript,
    00059       _S_basic,
    00060       _S_extended,
    00061       _S_awk,
    00062       _S_grep,
    00063       _S_egrep,
    00064       _S_syntax_last
    00065     };
    00066
    00067   /**
    00068    * @brief This is a bitmask type indicating how to interpret the regex.
    00069    *
    00070    * The @c syntax_option_type is implementation defined but it is valid to
    00071    * perform bitwise operations on these values and expect the right thing to
    00072    * happen.
    00073    *
    00074    * A valid value of type syntax_option_type shall have exactly one of the
    00075    * elements @c ECMAScript, @c basic, @c extended, @c awk, @c grep, @c egrep
    00076    * %set.
    00077    */
    00078   typedef unsigned int syntax_option_type;
    00079
    00080   /**
    00081    * Specifies that the matching of regular expressions against a character
    00082    * sequence shall be performed without regard to case.
    00083    */
    00084   static const syntax_option_type icase      = 1 << _S_icase;
    00085
    00086   /**
    00087    * Specifies that when a regular expression is matched against a character
    00088    * container sequence, no sub-expression matches are to be stored in the
    00089    * supplied match_results structure.
    00090    */
    00091   static const syntax_option_type nosubs     = 1 << _S_nosubs;
    00092
    00093   /**
    00094    * Specifies that the regular expression engine should pay more attention to
    00095    * the speed with which regular expressions are matched, and less to the
    00096    * speed with which regular expression objects are constructed. Otherwise
    00097    * it has no detectable effect on the program output.
    00098    */
    00099   static const syntax_option_type optimize   = 1 << _S_optimize;
    00100
    00101   /**
    00102    * Specifies that character ranges of the form [a-b] should be locale
    00103    * sensitive.
    00104    */
    00105   static const syntax_option_type collate    = 1 << _S_collate;
    00106
    00107   /**
    00108    * Specifies that the grammar recognized by the regular expression engine is
    00109    * that used by ECMAScript in ECMA-262 [Ecma International, ECMAScript
    00110    * Language Specification, Standard Ecma-262, third edition, 1999], as
    00111    * modified in tr1 section [7.13].  This grammar is similar to that defined
    00112    * in the PERL scripting language but extended with elements found in the
    00113    * POSIX regular expression grammar.
    00114    */
    00115   static const syntax_option_type ECMAScript = 1 << _S_ECMAScript;
    00116
    00117   /**
    00118    * Specifies that the grammar recognized by the regular expression engine is
    00119    * that used by POSIX basic regular expressions in IEEE Std 1003.1-2001,
    00120    * Portable Operating System Interface (POSIX), Base Definitions and
    00121    * Headers, Section 9, Regular Expressions [IEEE, Information Technology --
    00122    * Portable Operating System Interface (POSIX), IEEE Standard 1003.1-2001].
    00123    */
    00124   static const syntax_option_type basic      = 1 << _S_basic;
    00125
    00126   /**
    00127    * Specifies that the grammar recognized by the regular expression engine is
    00128    * that used by POSIX extended regular expressions in IEEE Std 1003.1-2001,
    00129    * Portable Operating System Interface (POSIX), Base Definitions and Headers,
    00130    * Section 9, Regular Expressions.
    00131    */
    00132   static const syntax_option_type extended   = 1 << _S_extended;
    00133
    00134   /**
    00135    * Specifies that the grammar recognized by the regular expression engine is
    00136    * that used by POSIX utility awk in IEEE Std 1003.1-2001.  This option is
    00137    * identical to syntax_option_type extended, except that C-style escape
    00138    * sequences are supported.  These sequences are, explicitly, "\\", "\a",
    00139    * "\b", "\f", "\n", "\r", "\t" , "\v", "\"", "'",
    00140    * and "\ddd" (where ddd is one, two, or three octal digits).
    00141    */
    00142   static const syntax_option_type awk        = 1 << _S_awk;
    00143
    00144   /**
    00145    * Specifies that the grammar recognized by the regular expression engine is
    00146    * that used by POSIX utility grep in IEEE Std 1003.1-2001.  This option is
    00147    * identical to syntax_option_type basic, except that newlines are treated
    00148    * as whitespace.
    00149    */
    00150   static const syntax_option_type grep       = 1 << _S_grep;
    00151
    00152   /**
    00153    * Specifies that the grammar recognized by the regular expression engine is
    00154    * that used by POSIX utility grep when given the -E option in
    00155    * IEEE Std 1003.1-2001.  This option is identical to syntax_option_type
    00156    * extended, except that newlines are treated as whitespace.
    00157    */
    00158   static const syntax_option_type egrep      = 1 << _S_egrep;
    00159
    00160   //@}
    00161
    00162   /**
    00163    * @name 5.2 Matching Rules
    00164    *
    00165    * Matching a regular expression against a sequence of characters [first,
    00166    * last) proceeds according to the rules of the grammar specified for the
    00167    * regular expression object, modified according to the effects listed
    00168    * below for any bitmask elements set.
    00169    *
    00170    */
    00171   //@{
    00172
    00173   enum __match_flag
    00174     {
    00175       _S_not_bol,
    00176       _S_not_eol,
    00177       _S_not_bow,
    00178       _S_not_eow,
    00179       _S_any,
    00180       _S_not_null,
    00181       _S_continuous,
    00182       _S_prev_avail,
    00183       _S_sed,
    00184       _S_no_copy,
    00185       _S_first_only,
    00186       _S_match_flag_last
    00187     };
    00188
    00189   /**
    00190    * @brief This is a bitmask type indicating regex matching rules.
    00191    *
    00192    * The @c match_flag_type is implementation defined but it is valid to
    00193    * perform bitwise operations on these values and expect the right thing to
    00194    * happen.
    00195    */
    00196   typedef std::bitset<_S_match_flag_last> match_flag_type;
    00197
    00198   /**
    00199    * The default matching rules.
    00200    */
    00201   static const match_flag_type match_default     = 0;
    00202
    00203   /**
    00204    * The first character in the sequence [first, last) is treated as though it
    00205    * is not at the beginning of a line, so the character "^" in the regular
    00206    * expression shall not match [first, first).
    00207    */
    00208   static const match_flag_type match_not_bol     = 1 << _S_not_bol;
    00209
    00210   /**
    00211    * The last character in the sequence [first, last) is treated as though it
    00212    * is not at the end of a line, so the character "$" in the regular
    00213    * expression shall not match [last, last).
    00214    */
    00215   static const match_flag_type match_not_eol     = 1 << _S_not_eol;
    00216
    00217   /**
    00218    * The expression "\b" is not matched against the sub-sequence
    00219    * [first,first).
    00220    */
    00221   static const match_flag_type match_not_bow     = 1 << _S_not_bow;
    00222
    00223   /**
    00224    * The expression "\b" should not be matched against the sub-sequence
    00225    * [last,last).
    00226    */
    00227   static const match_flag_type match_not_eow     = 1 << _S_not_eow;
    00228
    00229   /**
    00230    * If more than one match is possible then any match is an acceptable
    00231    * result.
    00232    */
    00233   static const match_flag_type match_any         = 1 << _S_any;
    00234
    00235   /**
    00236    * The expression does not match an empty sequence.
    00237    */
    00238   static const match_flag_type match_not_null    = 1 << _S_not_null;
    00239
    00240   /**
    00241    * The expression only matches a sub-sequence that begins at first .
    00242    */
    00243   static const match_flag_type match_continuous  = 1 << _S_continuous;
    00244
    00245   /**
    00246    * --first is a valid iterator position.  When this flag is set then the
    00247    * flags match_not_bol and match_not_bow are ignored by the regular
    00248    * expression algorithms 7.11 and iterators 7.12.
    00249    */
    00250   static const match_flag_type match_prev_avail  = 1 << _S_prev_avail;
    00251
    00252   /**
    00253    * When a regular expression match is to be replaced by a new string, the
    00254    * new string is constructed using the rules used by the ECMAScript replace
    00255    * function in ECMA- 262 [Ecma International, ECMAScript Language
    00256    * Specification, Standard Ecma-262, third edition, 1999], part 15.5.4.11
    00257    * String.prototype.replace. In addition, during search and replace
    00258    * operations all non-overlapping occurrences of the regular expression
    00259    * are located and replaced, and sections of the input that did not match
    00260    * the expression are copied unchanged to the output string.
    00261    *
    00262    * Format strings (from ECMA-262 [15.5.4.11]):
    00263    * @li $$  The dollar-sign itself ($)
    00264    * @li $&  The matched substring.
    00265    * @li $`  The portion of <em>string</em> that precedes the matched substring.
    00266    *         This would be match_results::prefix().
    00267    * @li $'  The portion of <em>string</em> that follows the matched substring.
    00268    *         This would be match_results::suffix().
    00269    * @li $n  The nth capture, where n is in [1,9] and $n is not followed by a
    00270    *         decimal digit.  If n <= match_results::size() and the nth capture
    00271    *         is undefined, use the empty string instead.  If n >
    00272    *         match_results::size(), the result is implementation-defined.
    00273    * @li $nn The nnth capture, where nn is a two-digit decimal number on
    00274    *         [01, 99].  If nn <= match_results::size() and the nth capture is
    00275    *         undefined, use the empty string instead. If
    00276    *         nn > match_results::size(), the result is implementation-defined.
    00277    */
    00278   static const match_flag_type format_default    = 0;
    00279
    00280   /**
    00281    * When a regular expression match is to be replaced by a new string, the
    00282    * new string is constructed using the rules used by the POSIX sed utility
    00283    * in IEEE Std 1003.1- 2001 [IEEE, Information Technology -- Portable
    00284    * Operating System Interface (POSIX), IEEE Standard 1003.1-2001].
    00285    */
    00286   static const match_flag_type format_sed        = 1 << _S_sed;
    00287
    00288   /**
    00289    * During a search and replace operation, sections of the character
    00290    * container sequence being searched that do not match the regular
    00291    * expression shall not be copied to the output string.
    00292    */
    00293   static const match_flag_type format_no_copy    = 1 << _S_no_copy;
    00294
    00295   /**
    00296    * When specified during a search and replace operation, only the first
    00297    * occurrence of the regular expression shall be replaced.
    00298    */
    00299   static const match_flag_type format_first_only = 1 << _S_first_only;
    00300
    00301   //@}
    00302
    00303   /**
    00304    * @name 5.3 Error Types
    00305    */
    00306   //@{
    00307
    00308   enum error_type
    00309     {
    00310       _S_error_collate,
    00311       _S_error_ctype,
    00312       _S_error_escape,
    00313       _S_error_backref,
    00314       _S_error_brack,
    00315       _S_error_paren,
    00316       _S_error_brace,
    00317       _S_error_badbrace,
    00318       _S_error_range,
    00319       _S_error_space,
    00320       _S_error_badrepeat,
    00321       _S_error_complexity,
    00322       _S_error_stack,
    00323       _S_error_last
    00324     };
    00325
    00326   /** The expression contained an invalid collating element name. */
    00327   static const error_type error_collate(_S_error_collate);
    00328
    00329   /** The expression contained an invalid character class name. */
    00330   static const error_type error_ctype(_S_error_ctype);
    00331
    00332   /**
    00333    * The expression contained an invalid escaped character, or a trailing
    00334    * escape.
    00335    */
    00336   static const error_type error_escape(_S_error_escape);
    00337
    00338   /** The expression contained an invalid back reference. */
    00339   static const error_type error_backref(_S_error_backref);
    00340
    00341   /** The expression contained mismatched [ and ]. */
    00342   static const error_type error_brack(_S_error_brack);
    00343
    00344   /** The expression contained mismatched ( and ). */
    00345   static const error_type error_paren(_S_error_paren);
    00346
    00347   /** The expression contained mismatched { and } */
    00348   static const error_type error_brace(_S_error_brace);
    00349
    00350   /** The expression contained an invalid range in a {} expression. */
    00351   static const error_type error_badbrace(_S_error_badbrace);
    00352
    00353   /**
    00354    * The expression contained an invalid character range,
    00355    * such as [b-a] in most encodings.
    00356    */
    00357   static const error_type error_range(_S_error_range);
    00358
    00359   /**
    00360    * There was insufficient memory to convert the expression into a
    00361    * finite state machine.
    00362    */
    00363   static const error_type error_space(_S_error_space);
    00364
    00365   /**
    00366    * One of "*?+{" was not preceded by a valid regular expression.
    00367    */
    00368   static const error_type error_badrepeat(_S_error_badrepeat);
    00369
    00370   /**
    00371    * The complexity of an attempted match against a regular expression
    00372    * exceeded a pre-set level.
    00373    */
    00374   static const error_type error_complexity(_S_error_complexity);
    00375
    00376   /**
    00377    * There was insufficient memory to determine whether the
    00378    * regular expression could match the specified character sequence.
    00379    */
    00380   static const error_type error_stack(_S_error_stack);
    00381
    00382   //@}
    00383 }
    00384
    00385
    00386   // [7.8] Class regex_error
    00387   /**
    00388    *  @brief A regular expression exception class.
    00389    *  @ingroup exceptions
    00390    *
    00391    *  The regular expression library throws objects of this class on error.
    00392    */
    00393   class regex_error
    00394   : public std::runtime_error
    00395   {
    00396   public:
    00397     /**
    00398      * @brief Constructs a regex_error object.
    00399      *
    00400      * @param ecode the regex error code.
    00401      */
    00402     explicit
    00403     regex_error(regex_constants::error_type __ecode)
    00404     : std::runtime_error("regex_error"), _M_code(__ecode)
    00405     { }
    00406
    00407     /**
    00408      * @brief Gets the regex error code.
    00409      *
    00410      * @returns the regex error code.
    00411      */
    00412     regex_constants::error_type
    00413     code() const
    00414     { return _M_code; }
    00415
    00416   protected:
    00417     regex_constants::error_type _M_code;
    00418   };
    00419
    00420   // [7.7] Class regex_traits
    00421   /**
    00422    * @brief Describes aspects of a regular expression.
    00423    *
    00424    * A regular expression traits class that satisfies the requirements of tr1
    00425    * section [7.2].
    00426    *
    00427    * The class %regex is parameterized around a set of related types and
    00428    * functions used to complete the definition of its semantics.  This class
    00429    * satisfies the requirements of such a traits class.
    00430    */
    00431   template<typename _Ch_type>
    00432     struct regex_traits
    00433     {
    00434     public:
    00435       typedef _Ch_type                     char_type;
    00436       typedef std::basic_string<char_type> string_type;
    00437       typedef std::locale                  locale_type;
    00438       typedef std::ctype_base::mask        char_class_type;
    00439
    00440     public:
    00441       /**
    00442        * @brief Constructs a default traits object.
    00443        */
    00444       regex_traits()
    00445       { }
    00446
    00447       /**
    00448        * @brief Gives the length of a C-style string starting at @p __p.
    00449        *
    00450        * @param __p a pointer to the start of a character sequence.
    00451        *
    00452        * @returns the number of characters between @p *__p and the first
    00453        * default-initialized value of type @p char_type.  In other words, uses
    00454        * the C-string algorithm for determining the length of a sequence of
    00455        * characters.
    00456        */
    00457       static std::size_t
    00458       length(const char_type* __p)
    00459       { return string_type::traits_type::length(__p); }
    00460
    00461       /**
    00462        * @brief Performs the identity translation.
    00463        *
    00464        * @param c A character to the locale-specific character set.
    00465        *
    00466        * @returns c.
    00467        */
    00468       char_type
    00469       translate(char_type __c) const
    00470       { return __c; }
    00471
    00472       /**
    00473        * @brief Translates a character into a case-insensitive equivalent.
    00474        *
    00475        * @param c A character to the locale-specific character set.
    00476        *
    00477        * @returns the locale-specific lower-case equivalent of c.
    00478        * @throws std::bad_cast if the imbued locale does not support the ctype
    00479        *         facet.
    00480        */
    00481       char_type
    00482       translate_nocase(char_type __c) const
    00483       {
    00484     using std::ctype;
    00485     using std::use_facet;
    00486     return use_facet<ctype<char_type> >(_M_locale).tolower(__c);
    00487       }
    00488
    00489       /**
    00490        * @brief Gets a sort key for a character sequence.
    00491        *
    00492        * @param first beginning of the character sequence.
    00493        * @param last  one-past-the-end of the character sequence.
    00494        *
    00495        * Returns a sort key for the character sequence designated by the
    00496        * iterator range [F1, F2) such that if the character sequence [G1, G2)
    00497        * sorts before the character sequence [H1, H2) then
    00498        * v.transform(G1, G2) < v.transform(H1, H2).
    00499        *
    00500        * What this really does is provide a more efficient way to compare a
    00501        * string to multiple other strings in locales with fancy collation
    00502        * rules and equivalence classes.
    00503        *
    00504        * @returns a locale-specific sort key equivalent to the input range.
    00505        *
    00506        * @throws std::bad_cast if the current locale does not have a collate
    00507        *         facet.
    00508        */
    00509       template<typename _Fwd_iter>
    00510         string_type
    00511         transform(_Fwd_iter __first, _Fwd_iter __last) const
    00512         {
    00513       using std::collate;
    00514       using std::use_facet;
    00515       const collate<_Ch_type>& __c(use_facet<
    00516                        collate<_Ch_type> >(_M_locale));
    00517       string_type __s(__first, __last);
    00518       return __c.transform(__s.data(), __s.data() + __s.size());
    00519     }
    00520
    00521       /**
    00522        * @brief Dunno.
    00523        *
    00524        * @param first beginning of the character sequence.
    00525        * @param last  one-past-the-end of the character sequence.
    00526        *
    00527        * Effects: if typeid(use_facet<collate<_Ch_type> >) ==
    00528        * typeid(collate_byname<_Ch_type>) and the form of the sort key
    00529        * returned by collate_byname<_Ch_type>::transform(first, last) is known
    00530        * and can be converted into a primary sort key then returns that key,
    00531        * otherwise returns an empty string. WTF??
    00532        *
    00533        * @todo Implement this function.
    00534        */
    00535       template<typename _Fwd_iter>
    00536         string_type
    00537         transform_primary(_Fwd_iter __first, _Fwd_iter __last) const;
    00538
    00539       /**
    00540        * @brief Gets a collation element by name.
    00541        *
    00542        * @param first beginning of the collation element name.
    00543        * @param last  one-past-the-end of the collation element name.
    00544        *
    00545        * @returns a sequence of one or more characters that represents the
    00546        * collating element consisting of the character sequence designated by
    00547        * the iterator range [first, last). Returns an empty string if the
    00548        * character sequence is not a valid collating element.
    00549        *
    00550        * @todo Implement this function.
    00551        */
    00552       template<typename _Fwd_iter>
    00553         string_type
    00554         lookup_collatename(_Fwd_iter __first, _Fwd_iter __last) const;
    00555
    00556       /**
    00557        * @brief Maps one or more characters to a named character
    00558        *        classification.
    00559        *
    00560        * @param first beginning of the character sequence.
    00561        * @param last  one-past-the-end of the character sequence.
    00562        *
    00563        * @returns an unspecified value that represents the character
    00564        * classification named by the character sequence designated by the
    00565        * iterator range [first, last). The value returned shall be independent
    00566        * of the case of the characters in the character sequence. If the name
    00567        * is not recognized then returns a value that compares equal to 0.
    00568        *
    00569        * At least the following names (or their wide-character equivalent) are
    00570        * supported.
    00571        * - d
    00572        * - w
    00573        * - s
    00574        * - alnum
    00575        * - alpha
    00576        * - blank
    00577        * - cntrl
    00578        * - digit
    00579        * - graph
    00580        * - lower
    00581        * - print
    00582        * - punct
    00583        * - space
    00584        * - upper
    00585        * - xdigit
    00586        *
    00587        * @todo Implement this function.
    00588        */
    00589       template<typename _Fwd_iter>
    00590         char_class_type
    00591         lookup_classname(_Fwd_iter __first, _Fwd_iter __last) const;
    00592
    00593       /**
    00594        * @brief Determines if @p c is a member of an identified class.
    00595        *
    00596        * @param c a character.
    00597        * @param f a class type (as returned from lookup_classname).
    00598        *
    00599        * @returns true if the character @p c is a member of the classification
    00600        * represented by @p f, false otherwise.
    00601        *
    00602        * @throws std::bad_cast if the current locale does not have a ctype
    00603        *         facet.
    00604        */
    00605       bool
    00606       isctype(_Ch_type __c, char_class_type __f) const;
    00607
    00608       /**
    00609        * @brief Converts a digit to an int.
    00610        *
    00611        * @param ch    a character representing a digit.
    00612        * @param radix the radix if the numeric conversion (limited to 8, 10,
    00613        *              or 16).
    00614        *
    00615        * @returns the value represented by the digit ch in base radix if the
    00616        * character ch is a valid digit in base radix; otherwise returns -1.
    00617        */
    00618       int
    00619       value(_Ch_type __ch, int __radix) const;
    00620
    00621       /**
    00622        * @brief Imbues the regex_traits object with a copy of a new locale.
    00623        *
    00624        * @param loc A locale.
    00625        *
    00626        * @returns a copy of the previous locale in use by the regex_traits
    00627        *          object.
    00628        *
    00629        * @note Calling imbue with a different locale than the one currently in
    00630        *       use invalidates all cached data held by *this.
    00631        */
    00632       locale_type
    00633       imbue(locale_type __loc)
    00634       {
    00635     std::swap(_M_locale, __loc);
    00636     return __loc;
    00637       }
    00638
    00639       /**
    00640        * @brief Gets a copy of the current locale in use by the regex_traits
    00641        * object.
    00642        */
    00643       locale_type
    00644       getloc() const
    00645       { return _M_locale; }
    00646
    00647     protected:
    00648       locale_type _M_locale;
    00649     };
    00650
    00651   template<typename _Ch_type>
    00652     bool regex_traits<_Ch_type>::
    00653     isctype(_Ch_type __c, char_class_type __f) const
    00654     {
    00655       using std::ctype;
    00656       using std::use_facet;
    00657       const ctype<_Ch_type>& __ctype(use_facet<
    00658                      ctype<_Ch_type> >(_M_locale));
    00659
    00660       if (__ctype.is(__c, __f))
    00661     return true;
    00662
    00663       // special case of underscore in [[:w:]]
    00664       if (__c == __ctype.widen('_'))
    00665     {
    00666       const char* const __wb[] = "w";
    00667       char_class_type __wt = this->lookup_classname(__wb,
    00668                             __wb + sizeof(__wb));
    00669       if (__f | __wt)
    00670         return true;
    00671     }
    00672
    00673       // special case of [[:space:]] in [[:blank:]]
    00674       if (__c == __ctype.isspace(__c))
    00675     {
    00676       const char* const __bb[] = "blank";
    00677       char_class_type __bt = this->lookup_classname(__bb,
    00678                             __bb + sizeof(__bb));
    00679       if (__f | __bt)
    00680         return true;
    00681     }
    00682
    00683       return false;
    00684     }
    00685
    00686   template<typename _Ch_type>
    00687     int regex_traits<_Ch_type>::
    00688     value(_Ch_type __ch, int __radix) const
    00689     {
    00690       std::basic_istringstream<_Ch_type> __is(string_type(1, __ch));
    00691       int __v = -1;
    00692       if (__radix == 8)
    00693     __is >> std::oct;
    00694       else if (__radix == 16)
    00695     __is >> std::hex;
    00696       __is >> __v;
    00697       return __v;
    00698     }
    00699
    00700   // [7.8] Class basic_regex
    00701   /**
    00702    * Objects of specializations of this class represent regular expressions
    00703    * constructed from sequences of character type @p _Ch_type.
    00704    *
    00705    * Storage for the regular expression is allocated and deallocated as
    00706    * necessary by the member functions of this class.
    00707    */
    00708   template<typename _Ch_type, typename _Rx_traits = regex_traits<_Ch_type> >
    00709     class basic_regex
    00710     {
    00711     public:
    00712       // types:
    00713       typedef _Ch_type                              value_type;
    00714       typedef regex_constants::syntax_option_type flag_type;
    00715       typedef typename _Rx_traits::locale_type  locale_type;
    00716       typedef typename _Rx_traits::string_type  string_type;
    00717
    00718       /**
    00719        * @name Constants
    00720        * tr1 [7.8.1] std [28.8.1]
    00721        */
    00722       //@{
    00723       static const regex_constants::syntax_option_type icase
    00724         = regex_constants::icase;
    00725       static const regex_constants::syntax_option_type nosubs
    00726         = regex_constants::nosubs;
    00727       static const regex_constants::syntax_option_type optimize
    00728         = regex_constants::optimize;
    00729       static const regex_constants::syntax_option_type collate
    00730         = regex_constants::collate;
    00731       static const regex_constants::syntax_option_type ECMAScript
    00732         = regex_constants::ECMAScript;
    00733       static const regex_constants::syntax_option_type basic
    00734         = regex_constants::basic;
    00735       static const regex_constants::syntax_option_type extended
    00736         = regex_constants::extended;
    00737       static const regex_constants::syntax_option_type awk
    00738         = regex_constants::awk;
    00739       static const regex_constants::syntax_option_type grep
    00740         = regex_constants::grep;
    00741       static const regex_constants::syntax_option_type egrep
    00742         = regex_constants::egrep;
    00743       //@}
    00744
    00745       // [7.8.2] construct/copy/destroy
    00746       /**
    00747        * Constructs a basic regular expression that does not match any
    00748        * character sequence.
    00749        */
    00750       basic_regex()
    00751       : _M_flags(regex_constants::ECMAScript), _M_pattern(), _M_mark_count(0)
    00752       { _M_compile(); }
    00753
    00754       /**
    00755        * @brief Constructs a basic regular expression from the sequence
    00756        * [p, p + char_traits<_Ch_type>::length(p)) interpreted according to the
    00757        * flags in @p f.
    00758        *
    00759        * @param p A pointer to the start of a C-style null-terminated string
    00760        *          containing a regular expression.
    00761        * @param f Flags indicating the syntax rules and options.
    00762        *
    00763        * @throws regex_error if @p p is not a valid regular expression.
    00764        */
    00765       explicit
    00766       basic_regex(const _Ch_type* __p,
    00767           flag_type __f = regex_constants::ECMAScript)
    00768       : _M_flags(__f), _M_pattern(__p), _M_mark_count(0)
    00769       { _M_compile(); }
    00770
    00771       /**
    00772        * @brief Constructs a basic regular expression from the sequence
    00773        * [p, p + len) interpreted according to the flags in @p f.
    00774        *
    00775        * @param p   A pointer to the start of a string containing a regular
    00776        *            expression.
    00777        * @param len The length of the string containing the regular expression.
    00778        * @param f   Flags indicating the syntax rules and options.
    00779        *
    00780        * @throws regex_error if @p p is not a valid regular expression.
    00781        */
    00782       basic_regex(const _Ch_type* __p, std::size_t __len, flag_type __f)
    00783       : _M_flags(__f) , _M_pattern(__p, __len), _M_mark_count(0)
    00784       { _M_compile(); }
    00785
    00786       /**
    00787        * @brief Copy-constructs a basic regular expression.
    00788        *
    00789        * @param rhs A @p regex object.
    00790      */
    00791       basic_regex(const basic_regex& __rhs)
    00792       : _M_flags(__rhs._M_flags), _M_pattern(__rhs._M_pattern),
    00793     _M_mark_count(__rhs._M_mark_count)
    00794       { _M_compile(); }
    00795
    00796       /**
    00797        * @brief Constructs a basic regular expression from the string
    00798        * @p s interpreted according to the flags in @p f.
    00799        *
    00800        * @param s A string containing a regular expression.
    00801        * @param f Flags indicating the syntax rules and options.
    00802        *
    00803        * @throws regex_error if @p s is not a valid regular expression.
    00804        */
    00805       template<typename _Ch_traits, typename _Ch_alloc>
    00806         explicit
    00807         basic_regex(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s,
    00808             flag_type __f = regex_constants::ECMAScript)
    00809     : _M_flags(__f), _M_pattern(__s.begin(), __s.end()), _M_mark_count(0)
    00810         { _M_compile(); }
    00811
    00812       /**
    00813        * @brief Constructs a basic regular expression from the range
    00814        * [first, last) interpreted according to the flags in @p f.
    00815        *
    00816        * @param first The start of a range containing a valid regular
    00817        *              expression.
    00818        * @param last  The end of a range containing a valid regular
    00819        *              expression.
    00820        * @param f     The format flags of the regular expression.
    00821        *
    00822        * @throws regex_error if @p [first, last) is not a valid regular
    00823        *         expression.
    00824        */
    00825       template<typename _InputIterator>
    00826         basic_regex(_InputIterator __first, _InputIterator __last,
    00827             flag_type __f = regex_constants::ECMAScript)
    00828     : _M_flags(__f), _M_pattern(__first, __last), _M_mark_count(0)
    00829         { _M_compile(); }
    00830
    00831 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
    00832       /**
    00833        * @brief Constructs a basic regular expression from an initializer list.
    00834        *
    00835        * @param l  The initializer list.
    00836        * @param f  The format flags of the regular expression.
    00837        *
    00838        * @throws regex_error if @p l is not a valid regular expression.
    00839        */
    00840       basic_regex(initializer_list<_Ch_type> __l,
    00841           flag_type __f = regex_constants::ECMAScript)
    00842     : _M_flags(__f), _M_pattern(__l.begin(), __l.end()), _M_mark_count(0)
    00843         { _M_compile(); }
    00844 #endif
    00845
    00846       /**
    00847        * @brief Destroys a basic regular expression.
    00848        */
    00849       ~basic_regex()
    00850       { }
    00851
    00852       /**
    00853        * @brief Assigns one regular expression to another.
    00854        */
    00855       basic_regex&
    00856       operator=(const basic_regex& __rhs)
    00857       { return this->assign(__rhs); }
    00858
    00859       /**
    00860        * @brief Replaces a regular expression with a new one constructed from
    00861        * a C-style null-terminated string.
    00862        *
    00863        * @param A pointer to the start of a null-terminated C-style string
    00864        *        containing a regular expression.
    00865        */
    00866       basic_regex&
    00867       operator=(const _Ch_type* __p)
    00868       { return this->assign(__p, flags()); }
    00869
    00870       /**
    00871        * @brief Replaces a regular expression with a new one constructed from
    00872        * a string.
    00873        *
    00874        * @param A pointer to a string containing a regular expression.
    00875        */
    00876       template<typename _Ch_typeraits, typename _Allocator>
    00877         basic_regex&
    00878         operator=(const basic_string<_Ch_type, _Ch_typeraits, _Allocator>& __s)
    00879         { return this->assign(__s, flags()); }
    00880
    00881       // [7.8.3] assign
    00882       /**
    00883        * @brief the real assignment operator.
    00884        *
    00885        * @param that Another regular expression object.
    00886        */
    00887       basic_regex&
    00888       assign(const basic_regex& __that)
    00889       {
    00890     basic_regex __tmp(__that);
    00891     this->swap(__tmp);
    00892     return *this;
    00893       }
    00894
    00895       /**
    00896        * @brief Assigns a new regular expression to a regex object from a
    00897        * C-style null-terminated string containing a regular expression
    00898        * pattern.
    00899        *
    00900        * @param p     A pointer to a C-style null-terminated string containing
    00901        *              a regular expression pattern.
    00902        * @param flags Syntax option flags.
    00903        *
    00904        * @throws regex_error if p does not contain a valid regular expression
    00905        * pattern interpreted according to @p flags.  If regex_error is thrown,
    00906        * *this remains unchanged.
    00907        */
    00908       basic_regex&
    00909       assign(const _Ch_type* __p,
    00910          flag_type __flags = regex_constants::ECMAScript)
    00911       { return this->assign(string_type(__p), __flags); }
    00912
    00913       /**
    00914        * @brief Assigns a new regular expression to a regex object from a
    00915        * C-style string containing a regular expression pattern.
    00916        *
    00917        * @param p     A pointer to a C-style string containing a
    00918        *              regular expression pattern.
    00919        * @param len   The length of the regular expression pattern string.
    00920        * @param flags Syntax option flags.
    00921        *
    00922        * @throws regex_error if p does not contain a valid regular expression
    00923        * pattern interpreted according to @p flags.  If regex_error is thrown,
    00924        * *this remains unchanged.
    00925        */
    00926       basic_regex&
    00927       assign(const _Ch_type* __p, std::size_t __len, flag_type __flags)
    00928       { return this->assign(string_type(__p, __len), __flags); }
    00929
    00930       /**
    00931        * @brief Assigns a new regular expression to a regex object from a
    00932        * string containing a regular expression pattern.
    00933        *
    00934        * @param s     A string containing a regular expression pattern.
    00935        * @param flags Syntax option flags.
    00936        *
    00937        * @throws regex_error if p does not contain a valid regular expression
    00938        * pattern interpreted according to @p flags.  If regex_error is thrown,
    00939        * *this remains unchanged.
    00940        */
    00941       template<typename _Ch_typeraits, typename _Allocator>
    00942         basic_regex&
    00943         assign(const basic_string<_Ch_type, _Ch_typeraits, _Allocator>& __s,
    00944            flag_type __f = regex_constants::ECMAScript)
    00945         {
    00946       basic_regex __tmp(__s, __f);
    00947       this->swap(__tmp);
    00948       return *this;
    00949     }
    00950
    00951       /**
    00952        * @brief Assigns a new regular expression to a regex object.
    00953        *
    00954        * @param first The start of a range containing a valid regular
    00955        *              expression.
    00956        * @param last  The end of a range containing a valid regular
    00957        *              expression.
    00958        * @param flags Syntax option flags.
    00959        *
    00960        * @throws regex_error if p does not contain a valid regular expression
    00961        * pattern interpreted according to @p flags.  If regex_error is thrown,
    00962        * the object remains unchanged.
    00963        */
    00964       template<typename _InputIterator>
    00965         basic_regex&
    00966         assign(_InputIterator __first, _InputIterator __last,
    00967            flag_type __flags = regex_constants::ECMAScript)
    00968         { return this->assign(string_type(__first, __last), __flags); }
    00969
    00970 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
    00971       /**
    00972        * @brief Assigns a new regular expression to a regex object.
    00973        *
    00974        * @param l     An initializer list representing a regular expression.
    00975        * @param flags Syntax option flags.
    00976        *
    00977        * @throws regex_error if @p l does not contain a valid regular
    00978        * expression pattern interpreted according to @p flags.  If regex_error
    00979        * is thrown, the object remains unchanged.
    00980        */
    00981       basic_regex&
    00982       assign(initializer_list<_Ch_type> __l,
    00983          flag_type __f = regex_constants::ECMAScript)
    00984       { return this->assign(__l.begin(), __l.end(), __f); }
    00985 #endif
    00986
    00987       // [7.8.4] const operations
    00988       /**
    00989        * @brief Gets the number of marked subexpressions within the regular
    00990        * expression.
    00991        */
    00992       unsigned int
    00993       mark_count() const
    00994       { return _M_mark_count; }
    00995
    00996       /**
    00997        * @brief Gets the flags used to construct the regular expression
    00998        * or in the last call to assign().
    00999        */
    01000       flag_type
    01001       flags() const
    01002       { return _M_flags; }
    01003
    01004       // [7.8.5] locale
    01005       /**
    01006        * @brief Imbues the regular expression object with the given locale.
    01007        *
    01008        * @param loc A locale.
    01009        */
    01010       locale_type
    01011       imbue(locale_type __loc)
    01012       { return _M_traits.imbue(__loc); }
    01013
    01014       /**
    01015        * @brief Gets the locale currently imbued in the regular expression
    01016        *        object.
    01017        */
    01018       locale_type
    01019       getloc() const
    01020       { return _M_traits.getloc(); }
    01021
    01022       // [7.8.6] swap
    01023       /**
    01024        * @brief Swaps the contents of two regular expression objects.
    01025        *
    01026        * @param rhs Another regular expression object.
    01027        */
    01028       void
    01029       swap(basic_regex& __rhs)
    01030       {
    01031     std::swap(_M_flags,      __rhs._M_flags);
    01032     std::swap(_M_pattern,    __rhs._M_pattern);
    01033     std::swap(_M_mark_count, __rhs._M_mark_count);
    01034     std::swap(_M_traits,     __rhs._M_traits);
    01035       }
    01036
    01037     private:
    01038       /**
    01039        * @brief Compiles a regular expression pattern into a NFA.
    01040        * @todo Implement this function.
    01041        */
    01042       void _M_compile();
    01043
    01044     protected:
    01045       flag_type    _M_flags;
    01046       string_type  _M_pattern;
    01047       unsigned int _M_mark_count;
    01048       _Rx_traits   _M_traits;
    01049     };
    01050
    01051   /** @brief Standard regular expressions. */
    01052   typedef basic_regex<char>    regex;
    01053 #ifdef _GLIBCXX_USE_WCHAR_T
    01054   /** @brief Standard wide-character regular expressions. */
    01055   typedef basic_regex<wchar_t> wregex;
    01056 #endif
    01057
    01058
    01059   // [7.8.6] basic_regex swap
    01060   /**
    01061    * @brief Swaps the contents of two regular expression objects.
    01062    * @param lhs First regular expression.
    01063    * @param rhs Second regular expression.
    01064    */
    01065   template<typename _Ch_type, typename _Rx_traits>
    01066     inline void
    01067     swap(basic_regex<_Ch_type, _Rx_traits>& __lhs,
    01068      basic_regex<_Ch_type, _Rx_traits>& __rhs)
    01069     { __lhs.swap(__rhs); }
    01070
    01071
    01072   // [7.9] Class template sub_match
    01073   /**
    01074    * A sequence of characters matched by a particular marked sub-expression.
    01075    *
    01076    * An object of this class is essentially a pair of iterators marking a
    01077    * matched subexpression within a regular expression pattern match. Such
    01078    * objects can be converted to and compared with std::basic_string objects
    01079    * of a similar base character type as the pattern matched by the regular
    01080    * expression.
    01081    *
    01082    * The iterators that make up the pair are the usual half-open interval
    01083    * referencing the actual original pattern matched.
    01084    */
    01085   template<typename _BiIter>
    01086     class sub_match : public std::pair<_BiIter, _BiIter>
    01087     {
    01088     public:
    01089       typedef typename iterator_traits<_BiIter>::value_type      value_type;
    01090       typedef typename iterator_traits<_BiIter>::difference_type
    01091                                                             difference_type;
    01092       typedef _BiIter                                              iterator;
    01093
    01094     public:
    01095       bool matched;
    01096
    01097       /**
    01098        * Gets the length of the matching sequence.
    01099        */
    01100       difference_type
    01101       length() const
    01102       { return this->matched ? std::distance(this->first, this->second) : 0; }
    01103
    01104       /**
    01105        * @brief Gets the matching sequence as a string.
    01106        *
    01107        * @returns the matching sequence as a string.
    01108        *
    01109        * This is the implicit conversion operator.  It is identical to the
    01110        * str() member function except that it will want to pop up in
    01111        * unexpected places and cause a great deal of confusion and cursing
    01112        * from the unwary.
    01113        */
    01114       operator basic_string<value_type>() const
    01115       {
    01116     return this->matched
    01117       ? std::basic_string<value_type>(this->first, this->second)
    01118       : std::basic_string<value_type>();
    01119       }
    01120
    01121       /**
    01122        * @brief Gets the matching sequence as a string.
    01123        *
    01124        * @returns the matching sequence as a string.
    01125        */
    01126       basic_string<value_type>
    01127       str() const
    01128       {
    01129     return this->matched
    01130       ? std::basic_string<value_type>(this->first, this->second)
    01131       : std::basic_string<value_type>();
    01132       }
    01133
    01134       /**
    01135        * @brief Compares this and another matched sequence.
    01136        *
    01137        * @param s Another matched sequence to compare to this one.
    01138        *
    01139        * @retval <0 this matched sequence will collate before @p s.
    01140        * @retval =0 this matched sequence is equivalent to @p s.
    01141        * @retval <0 this matched sequence will collate after @p s.
    01142        */
    01143       int
    01144       compare(const sub_match& __s) const
    01145       { return this->str().compare(__s.str()); }
    01146
    01147       /**
    01148        * @brief Compares this sub_match to a string.
    01149        *
    01150        * @param s A string to compare to this sub_match.
    01151        *
    01152        * @retval <0 this matched sequence will collate before @p s.
    01153        * @retval =0 this matched sequence is equivalent to @p s.
    01154        * @retval <0 this matched sequence will collate after @p s.
    01155        */
    01156       int
    01157       compare(const basic_string<value_type>& __s) const
    01158       { return this->str().compare(__s); }
    01159
    01160       /**
    01161        * @brief Compares this sub_match to a C-style string.
    01162        *
    01163        * @param s A C-style string to compare to this sub_match.
    01164        *
    01165        * @retval <0 this matched sequence will collate before @p s.
    01166        * @retval =0 this matched sequence is equivalent to @p s.
    01167        * @retval <0 this matched sequence will collate after @p s.
    01168        */
    01169       int
    01170       compare(const value_type* __s) const
    01171       { return this->str().compare(__s); }
    01172     };
    01173
    01174
    01175   /** @brief Standard regex submatch over a C-style null-terminated string. */
    01176   typedef sub_match<const char*>             csub_match;
    01177   /** @brief Standard regex submatch over a standard string. */
    01178   typedef sub_match<string::const_iterator>  ssub_match;
    01179 #ifdef _GLIBCXX_USE_WCHAR_T
    01180   /** @brief Regex submatch over a C-style null-terminated wide string. */
    01181   typedef sub_match<const wchar_t*>          wcsub_match;
    01182   /** @brief Regex submatch over a standard wide string. */
    01183   typedef sub_match<wstring::const_iterator> wssub_match;
    01184 #endif
    01185
    01186   // [7.9.2] sub_match non-member operators
    01187
    01188   /**
    01189    * @brief Tests the equivalence of two regular expression submatches.
    01190    * @param lhs First regular expression submatch.
    01191    * @param rhs Second regular expression submatch.
    01192    * @returns true if @a lhs  is equivalent to @a rhs, false otherwise.
    01193    */
    01194   template<typename _BiIter>
    01195     inline bool
    01196     operator==(const sub_match<_BiIter>& __lhs,
    01197            const sub_match<_BiIter>& __rhs)
    01198     { return __lhs.compare(__rhs) == 0; }
    01199
    01200   /**
    01201    * @brief Tests the inequivalence of two regular expression submatches.
    01202    * @param lhs First regular expression submatch.
    01203    * @param rhs Second regular expression submatch.
    01204    * @returns true if @a lhs  is not equivalent to @a rhs, false otherwise.
    01205    */
    01206   template<typename _BiIter>
    01207     inline bool
    01208     operator!=(const sub_match<_BiIter>& __lhs,
    01209            const sub_match<_BiIter>& __rhs)
    01210     { return __lhs.compare(__rhs) != 0; }
    01211
    01212   /**
    01213    * @brief Tests the ordering of two regular expression submatches.
    01214    * @param lhs First regular expression submatch.
    01215    * @param rhs Second regular expression submatch.
    01216    * @returns true if @a lhs precedes @a rhs, false otherwise.
    01217    */
    01218   template<typename _BiIter>
    01219     inline bool
    01220     operator<(const sub_match<_BiIter>& __lhs,
    01221           const sub_match<_BiIter>& __rhs)
    01222     { return __lhs.compare(__rhs) < 0; }
    01223
    01224   /**
    01225    * @brief Tests the ordering of two regular expression submatches.
    01226    * @param lhs First regular expression submatch.
    01227    * @param rhs Second regular expression submatch.
    01228    * @returns true if @a lhs does not succeed @a rhs, false otherwise.
    01229    */
    01230   template<typename _BiIter>
    01231     inline bool
    01232     operator<=(const sub_match<_BiIter>& __lhs,
    01233            const sub_match<_BiIter>& __rhs)
    01234     { return __lhs.compare(__rhs) <= 0; }
    01235
    01236   /**
    01237    * @brief Tests the ordering of two regular expression submatches.
    01238    * @param lhs First regular expression submatch.
    01239    * @param rhs Second regular expression submatch.
    01240    * @returns true if @a lhs does not precede @a rhs, false otherwise.
    01241    */
    01242   template<typename _BiIter>
    01243     inline bool
    01244     operator>=(const sub_match<_BiIter>& __lhs,
    01245            const sub_match<_BiIter>& __rhs)
    01246     { return __lhs.compare(__rhs) >= 0; }
    01247
    01248   /**
    01249    * @brief Tests the ordering of two regular expression submatches.
    01250    * @param lhs First regular expression submatch.
    01251    * @param rhs Second regular expression submatch.
    01252    * @returns true if @a lhs succeeds @a rhs, false otherwise.
    01253    */
    01254   template<typename _BiIter>
    01255     inline bool
    01256     operator>(const sub_match<_BiIter>& __lhs,
    01257           const sub_match<_BiIter>& __rhs)
    01258     { return __lhs.compare(__rhs) > 0; }
    01259
    01260   /**
    01261    * @brief Tests the equivalence of a string and a regular expression
    01262    *        submatch.
    01263    * @param lhs A string.
    01264    * @param rhs A regular expression submatch.
    01265    * @returns true if @a lhs  is equivalent to @a rhs, false otherwise.
    01266    */
    01267   template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
    01268     inline bool
    01269     operator==(const basic_string<
    01270            typename iterator_traits<_Bi_iter>::value_type,
    01271            _Ch_traits, _Ch_alloc>& __lhs,
    01272            const sub_match<_Bi_iter>& __rhs)
    01273     { return __lhs == __rhs.str(); }
    01274
    01275   /**
    01276    * @brief Tests the inequivalence of a string and a regular expression
    01277    *        submatch.
    01278    * @param lhs A string.
    01279    * @param rhs A regular expression submatch.
    01280    * @returns true if @a lhs  is not equivalent to @a rhs, false otherwise.
    01281    */
    01282   template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
    01283     inline bool
    01284     operator!=(const basic_string<
    01285            typename iterator_traits<_Bi_iter>::value_type,
    01286            _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs)
    01287     { return __lhs != __rhs.str(); }
    01288
    01289   /**
    01290    * @brief Tests the ordering of a string and a regular expression submatch.
    01291    * @param lhs A string.
    01292    * @param rhs A regular expression submatch.
    01293    * @returns true if @a lhs precedes @a rhs, false otherwise.
    01294    */
    01295   template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
    01296     inline bool
    01297     operator<(const basic_string<
    01298           typename iterator_traits<_Bi_iter>::value_type,
    01299           _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs)
    01300      { return __lhs < __rhs.str(); }
    01301
    01302   /**
    01303    * @brief Tests the ordering of a string and a regular expression submatch.
    01304    * @param lhs A string.
    01305    * @param rhs A regular expression submatch.
    01306    * @returns true if @a lhs succeeds @a rhs, false otherwise.
    01307    */
    01308   template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
    01309     inline bool
    01310     operator>(const basic_string<
    01311           typename iterator_traits<_Bi_iter>::value_type,
    01312           _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs)
    01313     { return __lhs > __rhs.str(); }
    01314
    01315   /**
    01316    * @brief Tests the ordering of a string and a regular expression submatch.
    01317    * @param lhs A string.
    01318    * @param rhs A regular expression submatch.
    01319    * @returns true if @a lhs does not precede @a rhs, false otherwise.
    01320    */
    01321   template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
    01322     inline bool
    01323     operator>=(const basic_string<
    01324            typename iterator_traits<_Bi_iter>::value_type,
    01325            _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs)
    01326     { return __lhs >= __rhs.str(); }
    01327
    01328   /**
    01329    * @brief Tests the ordering of a string and a regular expression submatch.
    01330    * @param lhs A string.
    01331    * @param rhs A regular expression submatch.
    01332    * @returns true if @a lhs does not succeed @a rhs, false otherwise.
    01333    */
    01334   template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
    01335     inline bool
    01336     operator<=(const basic_string<
    01337            typename iterator_traits<_Bi_iter>::value_type,
    01338            _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs)
    01339     { return __lhs <= __rhs.str(); }
    01340
    01341   /**
    01342    * @brief Tests the equivalence of a regular expression submatch and a
    01343    *        string.
    01344    * @param lhs A regular expression submatch.
    01345    * @param rhs A string.
    01346    * @returns true if @a lhs is equivalent to @a rhs, false otherwise.
    01347    */
    01348   template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
    01349     inline bool
    01350     operator==(const sub_match<_Bi_iter>& __lhs,
    01351            const basic_string<
    01352            typename iterator_traits<_Bi_iter>::value_type,
    01353            _Ch_traits, _Ch_alloc>& __rhs)
    01354     { return __lhs.str() == __rhs; }
    01355
    01356   /**
    01357    * @brief Tests the inequivalence of a regular expression submatch and a
    01358    *        string.
    01359    * @param lhs A regular expression submatch.
    01360    * @param rhs A string.
    01361    * @returns true if @a lhs is not equivalent to @a rhs, false otherwise.
    01362    */
    01363   template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
    01364     inline bool
    01365     operator!=(const sub_match<_Bi_iter>& __lhs,
    01366            const basic_string<
    01367            typename iterator_traits<_Bi_iter>::value_type,
    01368            _Ch_traits, _Ch_alloc>& __rhs)
    01369     { return __lhs.str() != __rhs; }
    01370
    01371   /**
    01372    * @brief Tests the ordering of a regular expression submatch and a string.
    01373    * @param lhs A regular expression submatch.
    01374    * @param rhs A string.
    01375    * @returns true if @a lhs precedes @a rhs, false otherwise.
    01376    */
    01377   template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc>
    01378     inline bool
    01379     operator<(const sub_match<_Bi_iter>& __lhs,
    01380           const basic_string<
    01381           typename iterator_traits<_Bi_iter>::value_type,
    01382           _Ch_traits, _Ch_alloc>& __rhs)
    01383     { return __lhs.str() < __rhs; }
    01384
    01385   /**
    01386    * @brief Tests the ordering of a regular expression submatch and a string.
    01387    * @param lhs A regular expression submatch.
    01388    * @param rhs A string.
    01389    * @returns true if @a lhs succeeds @a rhs, false otherwise.
    01390    */
    01391   template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc>
    01392     inline bool
    01393     operator>(const sub_match<_Bi_iter>& __lhs,
    01394           const basic_string<
    01395           typename iterator_traits<_Bi_iter>::value_type,
    01396           _Ch_traits, _Ch_alloc>& __rhs)
    01397     { return __lhs.str() > __rhs; }
    01398
    01399   /**
    01400    * @brief Tests the ordering of a regular expression submatch and a string.
    01401    * @param lhs A regular expression submatch.
    01402    * @param rhs A string.
    01403    * @returns true if @a lhs does not precede @a rhs, false otherwise.
    01404    */
    01405   template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc>
    01406     inline bool
    01407     operator>=(const sub_match<_Bi_iter>& __lhs,
    01408            const basic_string<
    01409            typename iterator_traits<_Bi_iter>::value_type,
    01410            _Ch_traits, _Ch_alloc>& __rhs)
    01411     { return __lhs.str() >= __rhs; }
    01412
    01413   /**
    01414    * @brief Tests the ordering of a regular expression submatch and a string.
    01415    * @param lhs A regular expression submatch.
    01416    * @param rhs A string.
    01417    * @returns true if @a lhs does not succeed @a rhs, false otherwise.
    01418    */
    01419   template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc>
    01420     inline bool
    01421     operator<=(const sub_match<_Bi_iter>& __lhs,
    01422            const basic_string<
    01423            typename iterator_traits<_Bi_iter>::value_type,
    01424            _Ch_traits, _Ch_alloc>& __rhs)
    01425     { return __lhs.str() <= __rhs; }
    01426
    01427   /**
    01428    * @brief Tests the equivalence of a C string and a regular expression
    01429    *        submatch.
    01430    * @param lhs A C string.
    01431    * @param rhs A regular expression submatch.
    01432    * @returns true if @a lhs  is equivalent to @a rhs, false otherwise.
    01433    */
    01434   template<typename _Bi_iter>
    01435     inline bool
    01436     operator==(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
    01437            const sub_match<_Bi_iter>& __rhs)
    01438     { return __lhs == __rhs.str(); }
    01439
    01440   /**
    01441    * @brief Tests the inequivalence of an iterator value and a regular
    01442    *        expression submatch.
    01443    * @param lhs A regular expression submatch.
    01444    * @param rhs A string.
    01445    * @returns true if @a lhs is not equivalent to @a rhs, false otherwise.
    01446    */
    01447   template<typename _Bi_iter>
    01448     inline bool
    01449     operator!=(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
    01450            const sub_match<_Bi_iter>& __rhs)
    01451     { return __lhs != __rhs.str(); }
    01452
    01453   /**
    01454    * @brief Tests the ordering of a string and a regular expression submatch.
    01455    * @param lhs A string.
    01456    * @param rhs A regular expression submatch.
    01457    * @returns true if @a lhs precedes @a rhs, false otherwise.
    01458    */
    01459   template<typename _Bi_iter>
    01460     inline bool
    01461     operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
    01462           const sub_match<_Bi_iter>& __rhs)
    01463     { return __lhs < __rhs.str(); }
    01464
    01465   /**
    01466    * @brief Tests the ordering of a string and a regular expression submatch.
    01467    * @param lhs A string.
    01468    * @param rhs A regular expression submatch.
    01469    * @returns true if @a lhs succeeds @a rhs, false otherwise.
    01470    */
    01471   template<typename _Bi_iter>
    01472     inline bool
    01473     operator>(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
    01474           const sub_match<_Bi_iter>& __rhs)
    01475     { return __lhs > __rhs.str(); }
    01476
    01477   /**
    01478    * @brief Tests the ordering of a string and a regular expression submatch.
    01479    * @param lhs A string.
    01480    * @param rhs A regular expression submatch.
    01481    * @returns true if @a lhs does not precede @a rhs, false otherwise.
    01482    */
    01483   template<typename _Bi_iter>
    01484     inline bool
    01485     operator>=(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
    01486            const sub_match<_Bi_iter>& __rhs)
    01487     { return __lhs >= __rhs.str(); }
    01488
    01489   /**
    01490    * @brief Tests the ordering of a string and a regular expression submatch.
    01491    * @param lhs A string.
    01492    * @param rhs A regular expression submatch.
    01493    * @returns true if @a lhs does not succeed @a rhs, false otherwise.
    01494    */
    01495   template<typename _Bi_iter>
    01496     inline bool
    01497     operator<=(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
    01498            const sub_match<_Bi_iter>& __rhs)
    01499     { return __lhs <= __rhs.str(); }
    01500
    01501   /**
    01502    * @brief Tests the equivalence of a regular expression submatch and a
    01503    *        string.
    01504    * @param lhs A regular expression submatch.
    01505    * @param rhs A pointer to a string?
    01506    * @returns true if @a lhs  is equivalent to @a rhs, false otherwise.
    01507    */
    01508   template<typename _Bi_iter>
    01509     inline bool
    01510     operator==(const sub_match<_Bi_iter>& __lhs,
    01511            typename iterator_traits<_Bi_iter>::value_type const* __rhs)
    01512     { return __lhs.str() == __rhs; }
    01513
    01514   /**
    01515    * @brief Tests the inequivalence of a regular expression submatch and a
    01516    *        string.
    01517    * @param lhs A regular expression submatch.
    01518    * @param rhs A pointer to a string.
    01519    * @returns true if @a lhs is not equivalent to @a rhs, false otherwise.
    01520    */
    01521   template<typename _Bi_iter>
    01522     inline bool
    01523     operator!=(const sub_match<_Bi_iter>& __lhs,
    01524            typename iterator_traits<_Bi_iter>::value_type const* __rhs)
    01525     { return __lhs.str() != __rhs; }
    01526
    01527   /**
    01528    * @brief Tests the ordering of a regular expression submatch and a string.
    01529    * @param lhs A regular expression submatch.
    01530    * @param rhs A string.
    01531    * @returns true if @a lhs precedes @a rhs, false otherwise.
    01532    */
    01533   template<typename _Bi_iter>
    01534     inline bool
    01535     operator<(const sub_match<_Bi_iter>& __lhs,
    01536           typename iterator_traits<_Bi_iter>::value_type const* __rhs)
    01537     { return __lhs.str() < __rhs; }
    01538
    01539   /**
    01540    * @brief Tests the ordering of a regular expression submatch and a string.
    01541    * @param lhs A regular expression submatch.
    01542    * @param rhs A string.
    01543    * @returns true if @a lhs succeeds @a rhs, false otherwise.
    01544    */
    01545   template<typename _Bi_iter>
    01546     inline bool
    01547     operator>(const sub_match<_Bi_iter>& __lhs,
    01548           typename iterator_traits<_Bi_iter>::value_type const* __rhs)
    01549     { return __lhs.str() > __rhs; }
    01550
    01551   /**
    01552    * @brief Tests the ordering of a regular expression submatch and a string.
    01553    * @param lhs A regular expression submatch.
    01554    * @param rhs A string.
    01555    * @returns true if @a lhs does not precede @a rhs, false otherwise.
    01556    */
    01557   template<typename _Bi_iter>
    01558     inline bool
    01559     operator>=(const sub_match<_Bi_iter>& __lhs,
    01560            typename iterator_traits<_Bi_iter>::value_type const* __rhs)
    01561     { return __lhs.str() >= __rhs; }
    01562
    01563   /**
    01564    * @brief Tests the ordering of a regular expression submatch and a string.
    01565    * @param lhs A regular expression submatch.
    01566    * @param rhs A string.
    01567    * @returns true if @a lhs does not succeed @a rhs, false otherwise.
    01568    */
    01569   template<typename _Bi_iter>
    01570     inline bool
    01571     operator<=(const sub_match<_Bi_iter>& __lhs,
    01572            typename iterator_traits<_Bi_iter>::value_type const* __rhs)
    01573     { return __lhs.str() <= __rhs; }
    01574
    01575   /**
    01576    * @brief Tests the equivalence of a string and a regular expression
    01577    *        submatch.
    01578    * @param lhs A string.
    01579    * @param rhs A regular expression submatch.
    01580    * @returns true if @a lhs is equivalent to @a rhs, false otherwise.
    01581    */
    01582   template<typename _Bi_iter>
    01583     inline bool
    01584     operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
    01585            const sub_match<_Bi_iter>& __rhs)
    01586     { return __lhs == __rhs.str(); }
    01587
    01588   /**
    01589    * @brief Tests the inequivalence of a string and a regular expression
    01590    *        submatch.
    01591    * @param lhs A string.
    01592    * @param rhs A regular expression submatch.
    01593    * @returns true if @a lhs is not equivalent to @a rhs, false otherwise.
    01594    */
    01595   template<typename _Bi_iter>
    01596     inline bool
    01597     operator!=(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
    01598            const sub_match<_Bi_iter>& __rhs)
    01599     { return __lhs != __rhs.str(); }
    01600
    01601   /**
    01602    * @brief Tests the ordering of a string and a regular expression submatch.
    01603    * @param lhs A string.
    01604    * @param rhs A regular expression submatch.
    01605    * @returns true if @a lhs precedes @a rhs, false otherwise.
    01606    */
    01607   template<typename _Bi_iter>
    01608     inline bool
    01609     operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
    01610           const sub_match<_Bi_iter>& __rhs)
    01611     { return __lhs < __rhs.str(); }
    01612
    01613   /**
    01614    * @brief Tests the ordering of a string and a regular expression submatch.
    01615    * @param lhs A string.
    01616    * @param rhs A regular expression submatch.
    01617    * @returns true if @a lhs succeeds @a rhs, false otherwise.
    01618    */
    01619   template<typename _Bi_iter>
    01620     inline bool
    01621     operator>(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
    01622           const sub_match<_Bi_iter>& __rhs)
    01623     { return __lhs > __rhs.str(); }
    01624
    01625   /**
    01626    * @brief Tests the ordering of a string and a regular expression submatch.
    01627    * @param lhs A string.
    01628    * @param rhs A regular expression submatch.
    01629    * @returns true if @a lhs does not precede @a rhs, false otherwise.
    01630    */
    01631   template<typename _Bi_iter>
    01632     inline bool
    01633     operator>=(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
    01634            const sub_match<_Bi_iter>& __rhs)
    01635     { return __lhs >= __rhs.str(); }
    01636
    01637   /**
    01638    * @brief Tests the ordering of a string and a regular expression submatch.
    01639    * @param lhs A string.
    01640    * @param rhs A regular expression submatch.
    01641    * @returns true if @a lhs does not succeed @a rhs, false otherwise.
    01642    */
    01643   template<typename _Bi_iter>
    01644     inline bool
    01645     operator<=(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
    01646            const sub_match<_Bi_iter>& __rhs)
    01647     { return __lhs <= __rhs.str(); }
    01648
    01649   /**
    01650    * @brief Tests the equivalence of a regular expression submatch and a
    01651    *        string.
    01652    * @param lhs A regular expression submatch.
    01653    * @param rhs A const string reference.
    01654    * @returns true if @a lhs  is equivalent to @a rhs, false otherwise.
    01655    */
    01656   template<typename _Bi_iter>
    01657     inline bool
    01658     operator==(const sub_match<_Bi_iter>& __lhs,
    01659            typename iterator_traits<_Bi_iter>::value_type const& __rhs)
    01660     { return __lhs.str() == __rhs; }
    01661
    01662   /**
    01663    * @brief Tests the inequivalence of a regular expression submatch and a
    01664    *        string.
    01665    * @param lhs A regular expression submatch.
    01666    * @param rhs A const string reference.
    01667    * @returns true if @a lhs is not equivalent to @a rhs, false otherwise.
    01668    */
    01669   template<typename _Bi_iter>
    01670     inline bool
    01671     operator!=(const sub_match<_Bi_iter>& __lhs,
    01672            typename iterator_traits<_Bi_iter>::value_type const& __rhs)
    01673     { return __lhs.str() != __rhs; }
    01674
    01675   /**
    01676    * @brief Tests the ordering of a regular expression submatch and a string.
    01677    * @param lhs A regular expression submatch.
    01678    * @param rhs A const string reference.
    01679    * @returns true if @a lhs precedes @a rhs, false otherwise.
    01680    */
    01681   template<typename _Bi_iter>
    01682     inline bool
    01683     operator<(const sub_match<_Bi_iter>& __lhs,
    01684           typename iterator_traits<_Bi_iter>::value_type const& __rhs)
    01685     { return __lhs.str() < __rhs; }
    01686
    01687   /**
    01688    * @brief Tests the ordering of a regular expression submatch and a string.
    01689    * @param lhs A regular expression submatch.
    01690    * @param rhs A const string reference.
    01691    * @returns true if @a lhs succeeds @a rhs, false otherwise.
    01692    */
    01693   template<typename _Bi_iter>
    01694     inline bool
    01695     operator>(const sub_match<_Bi_iter>& __lhs,
    01696           typename iterator_traits<_Bi_iter>::value_type const& __rhs)
    01697     { return __lhs.str() > __rhs; }
    01698
    01699   /**
    01700    * @brief Tests the ordering of a regular expression submatch and a string.
    01701    * @param lhs A regular expression submatch.
    01702    * @param rhs A const string reference.
    01703    * @returns true if @a lhs does not precede @a rhs, false otherwise.
    01704    */
    01705   template<typename _Bi_iter>
    01706     inline bool
    01707     operator>=(const sub_match<_Bi_iter>& __lhs,
    01708            typename iterator_traits<_Bi_iter>::value_type const& __rhs)
    01709     { return __lhs.str() >= __rhs; }
    01710
    01711   /**
    01712    * @brief Tests the ordering of a regular expression submatch and a string.
    01713    * @param lhs A regular expression submatch.
    01714    * @param rhs A const string reference.
    01715    * @returns true if @a lhs does not succeed @a rhs, false otherwise.
    01716    */
    01717   template<typename _Bi_iter>
    01718     inline bool
    01719     operator<=(const sub_match<_Bi_iter>& __lhs,
    01720            typename iterator_traits<_Bi_iter>::value_type const& __rhs)
    01721     { return __lhs.str() <= __rhs; }
    01722
    01723   /**
    01724    * @brief Inserts a matched string into an output stream.
    01725    *
    01726    * @param os The output stream.
    01727    * @param m  A submatch string.
    01728    *
    01729    * @returns the output stream with the submatch string inserted.
    01730    */
    01731   template<typename _Ch_type, typename _Ch_traits, typename _Bi_iter>
    01732     inline
    01733     basic_ostream<_Ch_type, _Ch_traits>&
    01734     operator<<(basic_ostream<_Ch_type, _Ch_traits>& __os,
    01735            const sub_match<_Bi_iter>& __m)
    01736     { return __os << __m.str(); }
    01737
    01738   // [7.10] Class template match_results
    01739   /**
    01740    * @brief The results of a match or search operation.
    01741    *
    01742    * A collection of character sequences representing the result of a regular
    01743    * expression match.  Storage for the collection is allocated and freed as
    01744    * necessary by the member functions of class template match_results.
    01745    *
    01746    * This class satisfies the Sequence requirements, with the exception that
    01747    * only the operations defined for a const-qualified Sequence are supported.
    01748    *
    01749    * The sub_match object stored at index 0 represents sub-expression 0, i.e.
    01750    * the whole match. In this case the sub_match member matched is always true.
    01751    * The sub_match object stored at index n denotes what matched the marked
    01752    * sub-expression n within the matched expression. If the sub-expression n
    01753    * participated in a regular expression match then the sub_match member
    01754    * matched evaluates to true, and members first and second denote the range
    01755    * of characters [first, second) which formed that match. Otherwise matched
    01756    * is false, and members first and second point to the end of the sequence
    01757    * that was searched.
    01758    *
    01759    * @nosubgrouping
    01760    */
    01761   template<typename _Bi_iter,
    01762        typename _Allocator = allocator<sub_match<_Bi_iter> > >
    01763     class match_results
    01764     : private std::vector<std::_GLIBCXX_TR1 sub_match<_Bi_iter>, _Allocator>
    01765     {
    01766     private:
    01767       typedef std::vector<std::_GLIBCXX_TR1 sub_match<_Bi_iter>, _Allocator>
    01768                                                               _Base_type;
    01769
    01770     public:
    01771       /**
    01772        * @name 10.? Public Types
    01773        */
    01774       //@{
    01775       typedef sub_match<_Bi_iter>                             value_type;
    01776       typedef typename _Allocator::const_reference            const_reference;
    01777       typedef const_reference                                 reference;
    01778       typedef typename _Base_type::const_iterator             const_iterator;
    01779       typedef const_iterator                                  iterator;
    01780       typedef typename iterator_traits<_Bi_iter>::difference_type
    01781                                                               difference_type;
    01782       typedef typename _Allocator::size_type                  size_type;
    01783       typedef _Allocator                                      allocator_type;
    01784       typedef typename iterator_traits<_Bi_iter>::value_type  char_type;
    01785       typedef basic_string<char_type>                         string_type;
    01786       //@}
    01787
    01788     public:
    01789       /**
    01790        * @name 10.1 Construction, Copying, and Destruction
    01791        */
    01792       //@{
    01793
    01794       /**
    01795        * @brief Constructs a default %match_results container.
    01796        * @post size() returns 0 and str() returns an empty string.
    01797        */
    01798       explicit
    01799       match_results(const _Allocator& __a = _Allocator())
    01800       : _Base_type(__a), _M_matched(false)
    01801       { }
    01802
    01803       /**
    01804        * @brief Copy constructs a %match_results.
    01805        */
    01806       match_results(const match_results& __rhs)
    01807       : _Base_type(__rhs), _M_matched(__rhs._M_matched),
    01808     _M_prefix(__rhs._M_prefix), _M_suffix(__rhs._M_suffix)
    01809       { }
    01810
    01811       /**
    01812        * @brief Assigns rhs to *this.
    01813        */
    01814       match_results&
    01815       operator=(const match_results& __rhs)
    01816       {
    01817     match_results __tmp(__rhs);
    01818     this->swap(__tmp);
    01819     return *this;
    01820       }
    01821
    01822       /**
    01823        * @brief Destroys a %match_results object.
    01824        */
    01825       ~match_results()
    01826       { }
    01827
    01828       //@}
    01829
    01830       /**
    01831        * @name 10.2 Size
    01832        */
    01833       //@{
    01834
    01835       /**
    01836        * @brief Gets the number of matches and submatches.
    01837        *
    01838        * The number of matches for a given regular expression will be either 0
    01839        * if there was no match or mark_count() + 1 if a match was successful.
    01840        * Some matches may be empty.
    01841        *
    01842        * @returns the number of matches found.
    01843        */
    01844       size_type
    01845       size() const
    01846       { return _M_matched ? _Base_type::size() + 1 : 0; }
    01847
    01848       //size_type
    01849       //max_size() const;
    01850       using _Base_type::max_size;
    01851
    01852       /**
    01853        * @brief Indicates if the %match_results contains no results.
    01854        * @retval true The %match_results object is empty.
    01855        * @retval false The %match_results object is not empty.
    01856        */
    01857       bool
    01858       empty() const
    01859       { return size() == 0; }
    01860
    01861       //@}
    01862
    01863       /**
    01864        * @name 10.3 Element Access
    01865        */
    01866       //@{
    01867
    01868       /**
    01869        * @brief Gets the length of the indicated submatch.
    01870        * @param sub indicates the submatch.
    01871        *
    01872        * This function returns the length of the indicated submatch, or the
    01873        * length of the entire match if @p sub is zero (the default).
    01874        */
    01875       difference_type
    01876       length(size_type __sub = 0) const
    01877       { return _M_matched ? this->str(__sub).length() : 0; }
    01878
    01879       /**
    01880        * @brief Gets the offset of the beginning of the indicated submatch.
    01881        * @param sub indicates the submatch.
    01882        *
    01883        * This function returns the offset from the beginning of the target
    01884        * sequence to the beginning of the submatch, unless the value of @p sub
    01885        * is zero (the default), in which case this function returns the offset
    01886        * from the beginning of the target sequence to the beginning of the
    01887        * match.
    01888        */
    01889       difference_type
    01890       position(size_type __sub = 0) const
    01891       {
    01892     return _M_matched ? std::distance(this->prefix().first,
    01893                       (*this)[__sub].first) : 0;
    01894       }
    01895
    01896       /**
    01897        * @brief Gets the match or submatch converted to a string type.
    01898        * @param sub indicates the submatch.
    01899        *
    01900        * This function gets the submatch (or match, if @p sub is zero) extracted
    01901        * from the target range and converted to the associated string type.
    01902        */
    01903       string_type
    01904       str(size_type __sub = 0) const
    01905       { return _M_matched ? (*this)[__sub].str() : string_type(); }
    01906
    01907       /**
    01908        * @brief Gets a %sub_match reference for the match or submatch.
    01909        * @param sub indicates the submatch.
    01910        *
    01911        * This function gets a reference to the indicated submatch, or the entire
    01912        * match if @p sub is zero.
    01913        *
    01914        * If @p sub >= size() then this function returns a %sub_match with a
    01915        * special value indicating no submatch.
    01916        */
    01917       const_reference
    01918       operator[](size_type __sub) const
    01919       { return _Base_type::operator[](__sub); }
    01920
    01921       /**
    01922        * @brief Gets a %sub_match representing the match prefix.
    01923        *
    01924        * This function gets a reference to a %sub_match object representing the
    01925        * part of the target range between the start of the target range and the
    01926        * start of the match.
    01927        */
    01928       const_reference
    01929       prefix() const
    01930       { return _M_prefix; }
    01931
    01932       /**
    01933        * @brief Gets a %sub_match representing the match suffix.
    01934        *
    01935        * This function gets a reference to a %sub_match object representing the
    01936        * part of the target range between the end of the match and the end of
    01937        * the target range.
    01938        */
    01939       const_reference
    01940       suffix() const
    01941       { return _M_suffix; }
    01942
    01943       /**
    01944        * @brief Gets an iterator to the start of the %sub_match collection.
    01945        */
    01946       const_iterator
    01947       begin() const
    01948       { return _Base_type::begin(); }
    01949
    01950 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
    01951       /**
    01952        * @brief Gets an iterator to the start of the %sub_match collection.
    01953        */
    01954       const_iterator
    01955       cbegin() const
    01956       { return _Base_type::begin(); }
    01957 #endif
    01958
    01959       /**
    01960        * @brief Gets an iterator to one-past-the-end of the collection.
    01961        */
    01962       const_iterator
    01963       end() const
    01964       { return _Base_type::end(); }
    01965
    01966 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
    01967       /**
    01968        * @brief Gets an iterator to one-past-the-end of the collection.
    01969        */
    01970       const_iterator
    01971       cend() const
    01972       { return _Base_type::end(); }
    01973 #endif
    01974
    01975       //@}
    01976
    01977       /**
    01978        * @name 10.4 Formatting
    01979        *
    01980        * These functions perform formatted substitution of the matched character
    01981        * sequences into their target.  The format specifiers and escape sequences
    01982        * accepted by these functions are determined by their @p flags parameter
    01983        * as documented above.
    01984        */
    01985        //@{
    01986
    01987       /**
    01988        * @todo Implement this function.
    01989        */
    01990       template<typename _Out_iter>
    01991         _Out_iter
    01992         format(_Out_iter __out, const string_type& __fmt,
    01993            regex_constants::match_flag_type __flags
    01994            = regex_constants::format_default) const;
    01995
    01996       /**
    01997        * @todo Implement this function.
    01998        */
    01999       string_type
    02000       format(const string_type& __fmt,
    02001          regex_constants::match_flag_type __flags
    02002          = regex_constants::format_default) const;
    02003
    02004       //@}
    02005
    02006       /**
    02007        * @name 10.5 Allocator
    02008        */
    02009       //@{
    02010
    02011       /**
    02012        * @brief Gets a copy of the allocator.
    02013        */
    02014       //allocator_type
    02015       //get_allocator() const;
    02016       using _Base_type::get_allocator;
    02017
    02018       //@}
    02019
    02020       /**
    02021        * @name 10.6 Swap
    02022        */
    02023        //@{
    02024
    02025       /**
    02026        * @brief Swaps the contents of two match_results.
    02027        */
    02028       void
    02029       swap(match_results& __that)
    02030       {
    02031     _Base_type::swap(__that);
    02032     std::swap(_M_matched, __that._M_matched);
    02033     std::swap(_M_prefix,  __that._M_prefix);
    02034     std::swap(_M_suffix,  __that._M_suffix);
    02035       }
    02036       //@}
    02037
    02038     private:
    02039       bool       _M_matched;
    02040       value_type _M_prefix;
    02041       value_type _M_suffix;
    02042     };
    02043
    02044   typedef match_results<const char*>             cmatch;
    02045   typedef match_results<string::const_iterator>  smatch;
    02046 #ifdef _GLIBCXX_USE_WCHAR_T
    02047   typedef match_results<const wchar_t*>          wcmatch;
    02048   typedef match_results<wstring::const_iterator> wsmatch;
    02049 #endif
    02050
    02051   // match_results comparisons
    02052   /**
    02053    * @brief Compares two match_results for equality.
    02054    * @returns true if the two objects refer to the same match,
    02055    * false otherwise.
    02056    * @todo Implement this function.
    02057    */
    02058   template<typename _Bi_iter, typename _Allocator>
    02059     inline bool
    02060     operator==(const match_results<_Bi_iter, _Allocator>& __m1,
    02061            const match_results<_Bi_iter, _Allocator>& __m2);
    02062
    02063   /**
    02064    * @brief Compares two match_results for inequality.
    02065    * @returns true if the two objects do not refer to the same match,
    02066    * false otherwise.
    02067    */
    02068   template<typename _Bi_iter, class _Allocator>
    02069     inline bool
    02070     operator!=(const match_results<_Bi_iter, _Allocator>& __m1,
    02071            const match_results<_Bi_iter, _Allocator>& __m2)
    02072     { return !(__m1 == __m2); }
    02073
    02074   // [7.10.6] match_results swap
    02075   /**
    02076    * @brief Swaps two match results.
    02077    * @param lhs A match result.
    02078    * @param rhs A match result.
    02079    *
    02080    * The contents of the two match_results objects are swapped.
    02081    */
    02082   template<typename _Bi_iter, typename _Allocator>
    02083     inline void
    02084     swap(match_results<_Bi_iter, _Allocator>& __lhs,
    02085      match_results<_Bi_iter, _Allocator>& __rhs)
    02086     { __lhs.swap(__rhs); }
    02087
    02088   // [7.11.2] Function template regex_match
    02089   /**
    02090    * @name Matching, Searching, and Replacing
    02091    */
    02092   //@{
    02093
    02094   /**
    02095    * @brief Determines if there is a match between the regular expression @p e
    02096    * and all of the character sequence [first, last).
    02097    *
    02098    * @param first Beginning of the character sequence to match.
    02099    * @param last  One-past-the-end of the character sequence to match.
    02100    * @param m     The match results.
    02101    * @param re    The regular expression.
    02102    * @param flags Controls how the regular expression is matched.
    02103    *
    02104    * @retval true  A match exists.
    02105    * @retval false Otherwise.
    02106    *
    02107    * @throws an exception of type regex_error.
    02108    *
    02109    * @todo Implement this function.
    02110    */
    02111   template<typename _Bi_iter, typename _Allocator,
    02112        typename _Ch_type, typename _Rx_traits>
    02113     bool
    02114     regex_match(_Bi_iter __first, _Bi_iter __last,
    02115         match_results<_Bi_iter, _Allocator>& __m,
    02116         const basic_regex<_Ch_type, _Rx_traits>& __re,
    02117         regex_constants::match_flag_type __flags
    02118         = regex_constants::match_default);
    02119
    02120   /**
    02121    * @brief Indicates if there is a match between the regular expression @p e
    02122    * and all of the character sequence [first, last).
    02123    *
    02124    * @param first Beginning of the character sequence to match.
    02125    * @param last  One-past-the-end of the character sequence to match.
    02126    * @param re    The regular expression.
    02127    * @param flags Controls how the regular expression is matched.
    02128    *
    02129    * @retval true  A match exists.
    02130    * @retval false Otherwise.
    02131    *
    02132    * @throws an exception of type regex_error.
    02133    */
    02134   template<typename _Bi_iter, typename _Ch_type, typename _Rx_traits>
    02135     bool
    02136     regex_match(_Bi_iter __first, _Bi_iter __last,
    02137         const basic_regex<_Ch_type, _Rx_traits>& __re,
    02138         regex_constants::match_flag_type __flags
    02139         = regex_constants::match_default)
    02140     {
    02141       match_results<_Bi_iter> __what;
    02142       return regex_match(__first, __last, __what, __re, __flags);
    02143     }
    02144
    02145   /**
    02146    * @brief Determines if there is a match between the regular expression @p e
    02147    * and a C-style null-terminated string.
    02148    *
    02149    * @param s  The C-style null-terminated string to match.
    02150    * @param m  The match results.
    02151    * @param re The regular expression.
    02152    * @param f  Controls how the regular expression is matched.
    02153    *
    02154    * @retval true  A match exists.
    02155    * @retval false Otherwise.
    02156    *
    02157    * @throws an exception of type regex_error.
    02158    */
    02159   template<typename _Ch_type, typename _Allocator, typename _Rx_traits>
    02160     inline bool
    02161     regex_match(const _Ch_type* __s,
    02162         match_results<const _Ch_type*, _Allocator>& __m,
    02163         const basic_regex<_Ch_type, _Rx_traits>& __re,
    02164         regex_constants::match_flag_type __f
    02165         = regex_constants::match_default)
    02166     { return regex_match(__s, __s + _Rx_traits::length(__s), __m, __re, __f); }
    02167
    02168   /**
    02169    * @brief Determines if there is a match between the regular expression @p e
    02170    * and a string.
    02171    *
    02172    * @param s     The string to match.
    02173    * @param m     The match results.
    02174    * @param re    The regular expression.
    02175    * @param flags Controls how the regular expression is matched.
    02176    *
    02177    * @retval true  A match exists.
    02178    * @retval false Otherwise.
    02179    *
    02180    * @throws an exception of type regex_error.
    02181    */
    02182   template<typename _Ch_traits, typename _Ch_alloc,
    02183        typename _Allocator, typename _Ch_type, typename _Rx_traits>
    02184     inline bool
    02185     regex_match(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s,
    02186         match_results<typename basic_string<_Ch_type,
    02187         _Ch_traits, _Ch_alloc>::const_iterator, _Allocator>& __m,
    02188         const basic_regex<_Ch_type, _Rx_traits>& __re,
    02189         regex_constants::match_flag_type __flags
    02190         = regex_constants::match_default)
    02191     { return regex_match(__s.begin(), __s.end(), __m, __re, __flags); }
    02192
    02193   /**
    02194    * @brief Indicates if there is a match between the regular expression @p e
    02195    * and a C-style null-terminated string.
    02196    *
    02197    * @param s  The C-style null-terminated string to match.
    02198    * @param re The regular expression.
    02199    * @param f  Controls how the regular expression is matched.
    02200    *
    02201    * @retval true  A match exists.
    02202    * @retval false Otherwise.
    02203    *
    02204    * @throws an exception of type regex_error.
    02205    */
    02206   template<typename _Ch_type, class _Rx_traits>
    02207     inline bool
    02208     regex_match(const _Ch_type* __s,
    02209         const basic_regex<_Ch_type, _Rx_traits>& __re,
    02210         regex_constants::match_flag_type __f
    02211         = regex_constants::match_default)
    02212     { return regex_match(__s, __s + _Rx_traits::length(__s), __re, __f); }
    02213
    02214   /**
    02215    * @brief Indicates if there is a match between the regular expression @p e
    02216    * and a string.
    02217    *
    02218    * @param s     [IN] The string to match.
    02219    * @param re    [IN] The regular expression.
    02220    * @param flags [IN] Controls how the regular expression is matched.
    02221    *
    02222    * @retval true  A match exists.
    02223    * @retval false Otherwise.
    02224    *
    02225    * @throws an exception of type regex_error.
    02226    */
    02227   template<typename _Ch_traits, typename _Str_allocator,
    02228        typename _Ch_type, typename _Rx_traits>
    02229     inline bool
    02230     regex_match(const basic_string<_Ch_type, _Ch_traits, _Str_allocator>& __s,
    02231         const basic_regex<_Ch_type, _Rx_traits>& __re,
    02232         regex_constants::match_flag_type __flags
    02233         = regex_constants::match_default)
    02234     { return regex_match(__s.begin(), __s.end(), __re, __flags); }
    02235
    02236   // [7.11.3] Function template regex_search
    02237   /**
    02238    * Searches for a regular expression within a range.
    02239    * @param first [IN]  The start of the string to search.
    02240    * @param last  [IN]  One-past-the-end of the string to search.
    02241    * @param m     [OUT] The match results.
    02242    * @param re    [IN]  The regular expression to search for.
    02243    * @param flags [IN]  Search policy flags.
    02244    * @retval true  A match was found within the string.
    02245    * @retval false No match was found within the string, the content of %m is
    02246    *               undefined.
    02247    *
    02248    * @throws an exception of type regex_error.
    02249    *
    02250    * @todo Implement this function.
    02251    */
    02252   template<typename _Bi_iter, typename _Allocator,
    02253        typename _Ch_type, typename _Rx_traits>
    02254     inline bool
    02255     regex_search(_Bi_iter __first, _Bi_iter __last,
    02256          match_results<_Bi_iter, _Allocator>& __m,
    02257          const basic_regex<_Ch_type, _Rx_traits>& __re,
    02258          regex_constants::match_flag_type __flags
    02259          = regex_constants::match_default);
    02260
    02261   /**
    02262    * Searches for a regular expression within a range.
    02263    * @param first [IN]  The start of the string to search.
    02264    * @param last  [IN]  One-past-the-end of the string to search.
    02265    * @param re    [IN]  The regular expression to search for.
    02266    * @param flags [IN]  Search policy flags.
    02267    * @retval true  A match was found within the string.
    02268    * @retval false No match was found within the string.
    02269    * @doctodo
    02270    *
    02271    * @throws an exception of type regex_error.
    02272    */
    02273   template<typename _Bi_iter, typename _Ch_type, typename _Rx_traits>
    02274     inline bool
    02275     regex_search(_Bi_iter __first, _Bi_iter __last,
    02276          const basic_regex<_Ch_type, _Rx_traits>& __re,
    02277          regex_constants::match_flag_type __flags
    02278          = regex_constants::match_default)
    02279     {
    02280       match_results<_Bi_iter> __what;
    02281       return regex_search(__first, __last, __what, __re, __flags);
    02282     }
    02283
    02284   /**
    02285    * @brief Searches for a regular expression within a C-string.
    02286    * @param s [IN]  A C-string to search for the regex.
    02287    * @param m [OUT] The set of regex matches.
    02288    * @param e [IN]  The regex to search for in @p s.
    02289    * @param f [IN]  The search flags.
    02290    * @retval true  A match was found within the string.
    02291    * @retval false No match was found within the string, the content of %m is
    02292    *               undefined.
    02293    * @doctodo
    02294    *
    02295    * @throws an exception of type regex_error.
    02296    */
    02297   template<typename _Ch_type, class _Allocator, class _Rx_traits>
    02298     inline bool
    02299     regex_search(const _Ch_type* __s,
    02300          match_results<const _Ch_type*, _Allocator>& __m,
    02301          const basic_regex<_Ch_type, _Rx_traits>& __e,
    02302          regex_constants::match_flag_type __f
    02303          = regex_constants::match_default)
    02304     { return regex_search(__s, __s + _Rx_traits::length(__s), __m, __e, __f); }
    02305
    02306   /**
    02307    * @brief Searches for a regular expression within a C-string.
    02308    * @param s [IN]  The C-string to search.
    02309    * @param e [IN]  The regular expression to search for.
    02310    * @param f [IN]  Search policy flags.
    02311    * @retval true  A match was found within the string.
    02312    * @retval false No match was found within the string.
    02313    * @doctodo
    02314    *
    02315    * @throws an exception of type regex_error.
    02316    */
    02317   template<typename _Ch_type, typename _Rx_traits>
    02318     inline bool
    02319     regex_search(const _Ch_type* __s,
    02320          const basic_regex<_Ch_type, _Rx_traits>& __e,
    02321          regex_constants::match_flag_type __f
    02322          = regex_constants::match_default)
    02323     { return regex_search(__s, __s + _Rx_traits::length(__s), __e, __f); }
    02324
    02325   /**
    02326    * @brief Searches for a regular expression within a string.
    02327    * @param s     [IN]  The string to search.
    02328    * @param e     [IN]  The regular expression to search for.
    02329    * @param flags [IN]  Search policy flags.
    02330    * @retval true  A match was found within the string.
    02331    * @retval false No match was found within the string.
    02332    * @doctodo
    02333    *
    02334    * @throws an exception of type regex_error.
    02335    */
    02336   template<typename _Ch_traits, typename _String_allocator,
    02337        typename _Ch_type, typename _Rx_traits>
    02338     inline bool
    02339     regex_search(const basic_string<_Ch_type, _Ch_traits,
    02340          _String_allocator>& __s,
    02341          const basic_regex<_Ch_type, _Rx_traits>& __e,
    02342          regex_constants::match_flag_type __flags
    02343          = regex_constants::match_default)
    02344     { return regex_search(__s.begin(), __s.end(), __e, __flags); }
    02345
    02346   /**
    02347    * @brief Searches for a regular expression within a string.
    02348    * @param s [IN]  A C++ string to search for the regex.
    02349    * @param m [OUT] The set of regex matches.
    02350    * @param e [IN]  The regex to search for in @p s.
    02351    * @param f [IN]  The search flags.
    02352    * @retval true  A match was found within the string.
    02353    * @retval false No match was found within the string, the content of %m is
    02354    *               undefined.
    02355    *
    02356    * @throws an exception of type regex_error.
    02357    */
    02358   template<typename _Ch_traits, typename _Ch_alloc,
    02359        typename _Allocator, typename _Ch_type,
    02360        typename _Rx_traits>
    02361     inline bool
    02362     regex_search(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s,
    02363          match_results<typename basic_string<_Ch_type,
    02364          _Ch_traits, _Ch_alloc>::const_iterator, _Allocator>& __m,
    02365          const basic_regex<_Ch_type, _Rx_traits>& __e,
    02366          regex_constants::match_flag_type __f
    02367          = regex_constants::match_default)
    02368     { return regex_search(__s.begin(), __s.end(), __m, __e, __f); }
    02369
    02370   // tr1 [7.11.4] std [28.11.4] Function template regex_replace
    02371   /**
    02372    * @doctodo
    02373    * @param out
    02374    * @param first
    02375    * @param last
    02376    * @param e
    02377    * @param fmt
    02378    * @param flags
    02379    *
    02380    * @returns out
    02381    * @throws an exception of type regex_error.
    02382    *
    02383    * @todo Implement this function.
    02384    */
    02385   template<typename _Out_iter, typename _Bi_iter,
    02386        typename _Rx_traits, typename _Ch_type>
    02387     inline _Out_iter
    02388     regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
    02389           const basic_regex<_Ch_type, _Rx_traits>& __e,
    02390           const basic_string<_Ch_type>& __fmt,
    02391           regex_constants::match_flag_type __flags
    02392           = regex_constants::match_default);
    02393
    02394   /**
    02395    * @doctodo
    02396    * @param s
    02397    * @param e
    02398    * @param fmt
    02399    * @param flags
    02400    *
    02401    * @returns a copy of string @p s with replacements.
    02402    *
    02403    * @throws an exception of type regex_error.
    02404    */
    02405   template<typename _Rx_traits, typename _Ch_type>
    02406     inline basic_string<_Ch_type>
    02407     regex_replace(const basic_string<_Ch_type>& __s,
    02408           const basic_regex<_Ch_type, _Rx_traits>& __e,
    02409           const basic_string<_Ch_type>& __fmt,
    02410           regex_constants::match_flag_type __flags
    02411           = regex_constants::match_default)
    02412     {
    02413       std::string __result;
    02414       regex_replace(std::back_inserter(__result),
    02415             __s.begin(), __s.end(), __e, __fmt, __flags);
    02416       return __result;
    02417     }
    02418
    02419   //@}
    02420
    02421   // tr1 [7.12.1] std [28.12] Class template regex_iterator
    02422   /**
    02423    * An iterator adaptor that will provide repeated calls of regex_search over
    02424    * a range until no more matches remain.
    02425    */
    02426   template<typename _Bi_iter,
    02427        typename _Ch_type = typename iterator_traits<_Bi_iter>::value_type,
    02428        typename _Rx_traits = regex_traits<_Ch_type> >
    02429     class regex_iterator
    02430     {
    02431     public:
    02432       typedef basic_regex<_Ch_type, _Rx_traits>  regex_type;
    02433       typedef match_results<_Bi_iter>            value_type;
    02434       typedef std::ptrdiff_t                     difference_type;
    02435       typedef const value_type*                  pointer;
    02436       typedef const value_type&                  reference;
    02437       typedef std::forward_iterator_tag          iterator_category;
    02438
    02439     public:
    02440       /**
    02441        * @brief Provides a singular iterator, useful for indicating
    02442        * one-past-the-end of a range.
    02443        * @todo Implement this function.
    02444        * @doctodo
    02445        */
    02446       regex_iterator();
    02447
    02448       /**
    02449        * Constructs a %regex_iterator...
    02450        * @param a  [IN] The start of a text range to search.
    02451        * @param b  [IN] One-past-the-end of the text range to search.
    02452        * @param re [IN] The regular expression to match.
    02453        * @param m  [IN] Policy flags for match rules.
    02454        * @todo Implement this function.
    02455        * @doctodo
    02456        */
    02457       regex_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type& __re,
    02458              regex_constants::match_flag_type __m
    02459              = regex_constants::match_default);
    02460
    02461       /**
    02462        * Copy constructs a %regex_iterator.
    02463        * @todo Implement this function.
    02464        * @doctodo
    02465        */
    02466       regex_iterator(const regex_iterator& __rhs);
    02467
    02468       /**
    02469        * @todo Implement this function.
    02470        * @doctodo
    02471        */
    02472       regex_iterator&
    02473       operator=(const regex_iterator& __rhs);
    02474
    02475       /**
    02476        * @todo Implement this function.
    02477        * @doctodo
    02478        */
    02479       bool
    02480       operator==(const regex_iterator& __rhs);
    02481
    02482       /**
    02483        * @todo Implement this function.
    02484        * @doctodo
    02485        */
    02486       bool
    02487       operator!=(const regex_iterator& __rhs);
    02488
    02489       /**
    02490        * @todo Implement this function.
    02491        * @doctodo
    02492        */
    02493       const value_type&
    02494       operator*();
    02495
    02496       /**
    02497        * @todo Implement this function.
    02498        * @doctodo
    02499        */
    02500       const value_type*
    02501       operator->();
    02502
    02503       /**
    02504        * @todo Implement this function.
    02505        * @doctodo
    02506        */
    02507       regex_iterator&
    02508       operator++();
    02509
    02510       /**
    02511        * @todo Implement this function.
    02512        * @doctodo
    02513        */
    02514       regex_iterator
    02515       operator++(int);
    02516
    02517     private:
    02518       // these members are shown for exposition only:
    02519       _Bi_iter                         begin;
    02520       _Bi_iter                         end;
    02521       const regex_type*                pregex;
    02522       regex_constants::match_flag_type flags;
    02523       match_results<_Bi_iter>          match;
    02524     };
    02525
    02526   typedef regex_iterator<const char*>             cregex_iterator;
    02527   typedef regex_iterator<string::const_iterator>  sregex_iterator;
    02528 #ifdef _GLIBCXX_USE_WCHAR_T
    02529   typedef regex_iterator<const wchar_t*>          wcregex_iterator;
    02530   typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
    02531 #endif
    02532
    02533   // [7.12.2] Class template regex_token_iterator
    02534   /**
    02535    * Iterates over submatches in a range (or "splits" a text string).
    02536    *
    02537    * The purpose of this iterator is to enumerate all, or all specified,
    02538    * matches of a regular expression within a text range.  The dereferenced
    02539    * value of an iterator of this class is a std::tr1::sub_match object.
    02540    */
    02541   template<typename _Bi_iter,
    02542        typename _Ch_type = typename iterator_traits<_Bi_iter>::value_type,
    02543        typename _Rx_traits = regex_traits<_Ch_type> >
    02544     class regex_token_iterator
    02545     {
    02546     public:
    02547       typedef basic_regex<_Ch_type, _Rx_traits> regex_type;
    02548       typedef sub_match<_Bi_iter>               value_type;
    02549       typedef std::ptrdiff_t                    difference_type;
    02550       typedef const value_type*                 pointer;
    02551       typedef const value_type&                 reference;
    02552       typedef std::forward_iterator_tag         iterator_category;
    02553
    02554     public:
    02555       /**
    02556        * @brief Default constructs a %regex_token_iterator.
    02557        * @todo Implement this function.
    02558        *
    02559        * A default-constructed %regex_token_iterator is a singular iterator
    02560        * that will compare equal to the one-past-the-end value for any
    02561        * iterator of the same type.
    02562        */
    02563       regex_token_iterator();
    02564
    02565       /**
    02566        * Constructs a %regex_token_iterator...
    02567        * @param a          [IN] The start of the text to search.
    02568        * @param b          [IN] One-past-the-end of the text to search.
    02569        * @param re         [IN] The regular expression to search for.
    02570        * @param submatch   [IN] Which submatch to return.  There are some
    02571        *                        special values for this parameter:
    02572        *                        - -1 each enumerated subexpression does NOT
    02573        *                          match the regular expression (aka field
    02574        *                          splitting)
    02575        *                        - 0 the entire string matching the
    02576        *                          subexpression is returned for each match
    02577        *                          within the text.
    02578        *                        - >0 enumerates only the indicated
    02579        *                          subexpression from a match within the text.
    02580        * @param m          [IN] Policy flags for match rules.
    02581        *
    02582        * @todo Implement this function.
    02583        * @doctodo
    02584        */
    02585       regex_token_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type& __re,
    02586                int __submatch = 0,
    02587                regex_constants::match_flag_type __m
    02588                = regex_constants::match_default);
    02589
    02590       /**
    02591        * Constructs a %regex_token_iterator...
    02592        * @param a          [IN] The start of the text to search.
    02593        * @param b          [IN] One-past-the-end of the text to search.
    02594        * @param re         [IN] The regular expression to search for.
    02595        * @param submatches [IN] A list of subexpressions to return for each
    02596        *                        regular expression match within the text.
    02597        * @param m          [IN] Policy flags for match rules.
    02598        *
    02599        * @todo Implement this function.
    02600        * @doctodo
    02601        */
    02602       regex_token_iterator(_Bi_iter __a, _Bi_iter __b,
    02603                const regex_type& __re,
    02604                const std::vector<int>& __submatches,
    02605                regex_constants::match_flag_type __m
    02606                  = regex_constants::match_default);
    02607
    02608       /**
    02609        * Constructs a %regex_token_iterator...
    02610        * @param a          [IN] The start of the text to search.
    02611        * @param b          [IN] One-past-the-end of the text to search.
    02612        * @param re         [IN] The regular expression to search for.
    02613        * @param submatches [IN] A list of subexpressions to return for each
    02614        *                        regular expression match within the text.
    02615        * @param m          [IN] Policy flags for match rules.
    02616
    02617        * @todo Implement this function.
    02618        * @doctodo
    02619        */
    02620       template<std::size_t _Nm>
    02621         regex_token_iterator(_Bi_iter __a, _Bi_iter __b,
    02622                  const regex_type& __re,
    02623                  const int (&__submatches)[_Nm],
    02624                  regex_constants::match_flag_type __m
    02625                  = regex_constants::match_default);
    02626
    02627       /**
    02628        * @brief Copy constructs a %regex_token_iterator.
    02629        * @param rhs [IN] A %regex_token_iterator to copy.
    02630        * @todo Implement this function.
    02631        */
    02632       regex_token_iterator(const regex_token_iterator& __rhs);
    02633
    02634       /**
    02635        * @brief Assigns a %regex_token_iterator to another.
    02636        * @param rhs [IN] A %regex_token_iterator to copy.
    02637        * @todo Implement this function.
    02638        */
    02639       regex_token_iterator&
    02640       operator=(const regex_token_iterator& __rhs);
    02641
    02642       /**
    02643        * @brief Compares a %regex_token_iterator to another for equality.
    02644        * @todo Implement this function.
    02645        */
    02646       bool
    02647       operator==(const regex_token_iterator& __rhs);
    02648
    02649       /**
    02650        * @brief Compares a %regex_token_iterator to another for inequality.
    02651        * @todo Implement this function.
    02652        */
    02653       bool
    02654       operator!=(const regex_token_iterator& __rhs);
    02655
    02656       /**
    02657        * @brief Dereferences a %regex_token_iterator.
    02658        * @todo Implement this function.
    02659        */
    02660       const value_type&
    02661       operator*();
    02662
    02663       /**
    02664        * @brief Selects a %regex_token_iterator member.
    02665        * @todo Implement this function.
    02666        */
    02667       const value_type*
    02668       operator->();
    02669
    02670       /**
    02671        * @brief Increments a %regex_token_iterator.
    02672        * @todo Implement this function.
    02673        */
    02674       regex_token_iterator&
    02675       operator++();
    02676
    02677       /**
    02678        * @brief Postincrements a %regex_token_iterator.
    02679        * @todo Implement this function.
    02680        */
    02681       regex_token_iterator
    02682       operator++(int);
    02683
    02684     private: // data members for exposition only:
    02685       typedef regex_iterator<_Bi_iter, _Ch_type, _Rx_traits> position_iterator;
    02686
    02687       position_iterator __position;
    02688       const value_type* __result;
    02689       value_type        __suffix;
    02690       std::size_t       __n;
    02691       std::vector<int>  __subs;
    02692     };
    02693
    02694   /** @brief Token iterator for C-style NULL-terminated strings. */
    02695   typedef regex_token_iterator<const char*>             cregex_token_iterator;
    02696   /** @brief Token iterator for standard strings. */
    02697   typedef regex_token_iterator<string::const_iterator>  sregex_token_iterator;
    02698 #ifdef _GLIBCXX_USE_WCHAR_T
    02699   /** @brief Token iterator for C-style NULL-terminated wide strings. */
    02700   typedef regex_token_iterator<const wchar_t*>          wcregex_token_iterator;
    02701   /** @brief Token iterator for standard wide-character strings. */
    02702   typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
    02703 #endif
    02704
    02705   //@}
    02706
    02707 _GLIBCXX_END_NAMESPACE_TR1
    02708 }