# tr1_impl/regex

Go to the documentation of this file.

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