From 34d1ff06bf3d8df09bbb2c0caf7d4c6bc0de5d2a Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Fri, 8 Nov 2013 14:30:40 +0000 Subject: [PATCH] regex_compiler.h (__detail::__compile_nfa): Overload so that std::basic_string and std::vector iterators dispatch to... * include/bits/regex_compiler.h (__detail::__compile_nfa): Overload so that std::basic_string and std::vector iterators dispatch to the const C* compiler. From-SVN: r204574 --- libstdc++-v3/ChangeLog | 4 ++ libstdc++-v3/include/bits/regex_compiler.h | 44 +++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 93203c243e0..ea2e6c7eee9 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -28,6 +28,10 @@ _CharT template parameters. * include/bits/regex_compiler.tcc: Likewise. + * include/bits/regex_compiler.h (__detail::__compile_nfa): Overload + so that std::basic_string and std::vector iterators dispatch to + the const C* compiler. + 2013-11-06 Jonathan Wakely * include/bits/regex_automaton.h (_S_opcode_word_boundry): Rename to diff --git a/libstdc++-v3/include/bits/regex_compiler.h b/libstdc++-v3/include/bits/regex_compiler.h index 406d9a9fd6b..741098f8c64 100644 --- a/libstdc++-v3/include/bits/regex_compiler.h +++ b/libstdc++-v3/include/bits/regex_compiler.h @@ -129,8 +129,40 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _StackT _M_stack; }; + template + struct __has_contiguous_iter : std::false_type { }; + + template + struct __has_contiguous_iter> + : std::true_type + { }; + + template + struct __has_contiguous_iter> + : std::true_type + { }; + + template + struct __is_contiguous_normal_iter : std::false_type { }; + + template + struct + __is_contiguous_normal_iter<__gnu_cxx::__normal_iterator<_Tp, _Cont>> + : __has_contiguous_iter<_Cont>::type + { }; + + template + using __enable_if_contiguous_normal_iter + = typename enable_if< __is_contiguous_normal_iter<_Iter>::value, + std::shared_ptr<_NFA<_TraitsT>> >::type; + + template + using __disable_if_contiguous_normal_iter + = typename enable_if< !__is_contiguous_normal_iter<_Iter>::value, + std::shared_ptr<_NFA<_TraitsT>> >::type; + template - inline std::shared_ptr<_NFA<_TraitsT>> + inline __disable_if_contiguous_normal_iter<_FwdIter, _TraitsT> __compile_nfa(_FwdIter __first, _FwdIter __last, const _TraitsT& __traits, regex_constants::syntax_option_type __flags) { @@ -138,6 +170,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return _Cmplr(__first, __last, __traits, __flags)._M_get_nfa(); } + template + inline __enable_if_contiguous_normal_iter<_Iter, _TraitsT> + __compile_nfa(_Iter __first, _Iter __last, const _TraitsT& __traits, + regex_constants::syntax_option_type __flags) + { + size_t __len = __last - __first; + const auto* __cfirst = __len ? std::__addressof(*__first) : nullptr; + return __compile_nfa(__cfirst, __cfirst + __len, __traits, __flags); + } + template struct _AnyMatcher { -- 2.30.2