regex.h (regex_token_iterator<>::regex_token_iterator): Fix initialization orders...
[gcc.git] / libstdc++-v3 / include / bits / regex.h
index 4d7e7d7ff3634337fa50924d9e7f4afb2fd8745e..5d1a8f4b71ed82b5dafca809e995ae42a7755c64 100644 (file)
@@ -32,6 +32,24 @@ namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
+namespace __detail
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+  template<typename _BiIter, typename _Alloc,
+          typename _CharT, typename _TraitsT,
+          _RegexExecutorPolicy __policy,
+          bool __match_mode>
+    bool
+    __regex_algo_impl(_BiIter                              __s,
+                     _BiIter                              __e,
+                     match_results<_BiIter, _Alloc>&      __m,
+                     const basic_regex<_CharT, _TraitsT>& __re,
+                     regex_constants::match_flag_type     __flags);
+
+_GLIBCXX_END_NAMESPACE_VERSION
+}
+
   /**
    * @addtogroup regex
    * @{
@@ -713,7 +731,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        _AutomatonPtr;
 
       template<typename _BiIter, typename _Alloc,
-       typename _CharT, typename _TraitsT>
+       typename _CharT, typename _TraitsT,
+       __detail::_RegexExecutorPolicy __policy>
        friend std::unique_ptr<
          __detail::_Executor<_BiIter, _Alloc, _CharT, _TraitsT>>
        __detail::__get_executor(_BiIter,
@@ -722,19 +741,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                                 const basic_regex<_CharT, _TraitsT>&,
                                 regex_constants::match_flag_type);
 
-      template<typename _Bp, typename _Ap, typename _Cp, typename _Rp>
+      template<typename _Bp, typename _Ap, typename _Cp, typename _Rp,
+       __detail::_RegexExecutorPolicy, bool>
        friend bool
-       regex_match(_Bp, _Bp,
-                   match_results<_Bp, _Ap>&,
-                   const basic_regex<_Cp, _Rp>&,
-                   regex_constants::match_flag_type);
-
-      template<typename _Bp, typename _Ap, typename _Cp, typename _Rp>
-       friend bool
-       regex_search(_Bp, _Bp,
-                    match_results<_Bp, _Ap>&,
-                    const basic_regex<_Cp, _Rp>&,
-                    regex_constants::match_flag_type);
+       __detail::__regex_algo_impl(_Bp, _Bp, match_results<_Bp, _Ap>&,
+                                   const basic_regex<_Cp, _Rp>&,
+                                   regex_constants::match_flag_type);
 
       template<typename, typename, typename, typename>
        friend class __detail::_Executor;
@@ -1851,21 +1863,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       template<typename, typename, typename>
        friend class regex_iterator;
 
-      template<typename _Bp, typename _Ap,
-       typename _Ch_type, typename _Rx_traits>
-       friend bool
-       regex_match(_Bp, _Bp, match_results<_Bp, _Ap>&,
-                   const basic_regex<_Ch_type,
-                   _Rx_traits>&,
-                   regex_constants::match_flag_type);
-
-      template<typename _Bp, typename _Ap,
-       typename _Ch_type, typename _Rx_traits>
+      template<typename _Bp, typename _Ap, typename _Cp, typename _Rp,
+       __detail::_RegexExecutorPolicy, bool>
        friend bool
-       regex_search(_Bp, _Bp, match_results<_Bp, _Ap>&,
-                    const basic_regex<_Ch_type,
-                    _Rx_traits>&,
-                    regex_constants::match_flag_type);
+       __detail::__regex_algo_impl(_Bp, _Bp, match_results<_Bp, _Ap>&,
+                                   const basic_regex<_Cp, _Rp>&,
+                                   regex_constants::match_flag_type);
 
       _Bi_iter _M_begin;
       bool     _M_in_iterator;
@@ -1951,13 +1954,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    */
   template<typename _Bi_iter, typename _Alloc,
           typename _Ch_type, typename _Rx_traits>
-    bool
+    inline bool
     regex_match(_Bi_iter                                 __s,
                _Bi_iter                                 __e,
                match_results<_Bi_iter, _Alloc>&         __m,
                const basic_regex<_Ch_type, _Rx_traits>& __re,
                regex_constants::match_flag_type         __flags
-                              = regex_constants::match_default);
+                              = regex_constants::match_default)
+    {
+      return __detail::__regex_algo_impl<_Bi_iter, _Alloc, _Ch_type, _Rx_traits,
+       __detail::_RegexExecutorPolicy::_S_auto, true>
+         (__s, __e, __m, __re, __flags);
+    }
 
   /**
    * @brief Indicates if there is a match between the regular expression @p e
@@ -2091,12 +2099,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    */
   template<typename _Bi_iter, typename _Alloc,
           typename _Ch_type, typename _Rx_traits>
-    bool
-    regex_search(_Bi_iter __first, _Bi_iter __last,
+    inline bool
+    regex_search(_Bi_iter __s, _Bi_iter __e,
                 match_results<_Bi_iter, _Alloc>& __m,
                 const basic_regex<_Ch_type, _Rx_traits>& __re,
                 regex_constants::match_flag_type __flags
-                = regex_constants::match_default);
+                = regex_constants::match_default)
+    {
+      return __detail::__regex_algo_impl<_Bi_iter, _Alloc, _Ch_type, _Rx_traits,
+       __detail::_RegexExecutorPolicy::_S_auto, false>
+         (__s, __e, __m, __re, __flags);
+    }
 
   /**
    * Searches for a regular expression within a range.
@@ -2501,7 +2514,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        * iterator of the same type.
        */
       regex_token_iterator()
-      : _M_position(), _M_result(nullptr), _M_suffix(), _M_n(0), _M_subs()
+      : _M_position(), _M_subs(), _M_suffix(), _M_n(0), _M_result(nullptr),
+      _M_has_m1(false)
       { }
 
       /**
@@ -2586,8 +2600,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        * @param __rhs [IN] A %regex_token_iterator to copy.
        */
       regex_token_iterator(const regex_token_iterator& __rhs)
-      : _M_position(__rhs.position), _M_subs(__rhs.subs), _M_n(__rhs.N),
-      _M_result(__rhs.result), _M_suffix(__rhs.suffix),
+      : _M_position(__rhs._M_position), _M_subs(__rhs._M_subs),
+      _M_suffix(__rhs._M_suffix), _M_n(__rhs._M_n), _M_result(__rhs._M_result),
       _M_has_m1(__rhs._M_has_m1)
       {
        if (__rhs._M_result == &__rhs._M_suffix)
@@ -2665,10 +2679,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       { return _M_result == nullptr; }
 
       _Position         _M_position;
-      const value_type* _M_result;
+      std::vector<int>  _M_subs;
       value_type        _M_suffix;
       std::size_t       _M_n;
-      std::vector<int>  _M_subs;
+      const value_type* _M_result;
 
       // Show whether _M_subs contains -1
       bool              _M_has_m1;