From 06bbcf59db3e58b29025d0fe15201b0261744780 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Sun, 11 Jan 2009 17:25:23 +0000 Subject: [PATCH] regex (basic_regex::basic_regex): Use range constructor for _M_pattern. * include/tr1_impl/regex (basic_regex::basic_regex): Use range constructor for _M_pattern. * testsuite/tr1/7_regular_expressions/basic_regex/ctors/char/ string.cc: Test construction from different basic_string type. * testsuite/tr1/7_regular_expressions/basic_regex/ctors/wchar_t/ string.cc: Likewise. From-SVN: r143275 --- libstdc++-v3/ChangeLog | 9 +++++++++ libstdc++-v3/include/tr1_impl/regex | 8 ++++---- .../basic_regex/ctors/char/string.cc | 11 +++++++++++ .../basic_regex/ctors/wchar_t/string.cc | 11 +++++++++++ 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 02bfce7939b5..e56bd23ac2a2 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,12 @@ +2009-01-11 Jonathan Wakely + + * include/tr1_impl/regex (basic_regex::basic_regex): Use range + constructor for _M_pattern. + * testsuite/tr1/7_regular_expressions/basic_regex/ctors/char/ + string.cc: Test construction from different basic_string type. + * testsuite/tr1/7_regular_expressions/basic_regex/ctors/wchar_t/ + string.cc: Likewise. + 2009-01-07 Benjamin Kosnik Jonathan Larmour diff --git a/libstdc++-v3/include/tr1_impl/regex b/libstdc++-v3/include/tr1_impl/regex index 2e7984127b02..80bc394e96d7 100644 --- a/libstdc++-v3/include/tr1_impl/regex +++ b/libstdc++-v3/include/tr1_impl/regex @@ -796,18 +796,18 @@ namespace regex_constants /** * @brief Constructs a basic regular expression from the string - * @p interpreted according to the flags in @p f. + * @p s interpreted according to the flags in @p f. * - * @param p A string containing a regular expression. + * @param s A string containing a regular expression. * @param f Flags indicating the syntax rules and options. * - * @throws regex_error if @p p is not a valid regular expression. + * @throws regex_error if @p s is not a valid regular expression. */ template explicit basic_regex(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s, flag_type __f = regex_constants::ECMAScript) - : _M_flags(__f), _M_pattern(__s), _M_mark_count(0) + : _M_flags(__f), _M_pattern(__s.begin(), __s.end()), _M_mark_count(0) { _M_compile(); } /** diff --git a/libstdc++-v3/testsuite/tr1/7_regular_expressions/basic_regex/ctors/char/string.cc b/libstdc++-v3/testsuite/tr1/7_regular_expressions/basic_regex/ctors/char/string.cc index c2fb2c7d51c3..39cce6c64726 100644 --- a/libstdc++-v3/testsuite/tr1/7_regular_expressions/basic_regex/ctors/char/string.cc +++ b/libstdc++-v3/testsuite/tr1/7_regular_expressions/basic_regex/ctors/char/string.cc @@ -25,6 +25,7 @@ #include #include #include +#include // Tests C++ string constructor of the basic_regex class. void test01() @@ -35,9 +36,19 @@ void test01() test_type re(s); } +void test02() +{ + typedef std::tr1::basic_regex test_type; + typedef __gnu_test::tracker_allocator alloc_type; + + std::basic_string, alloc_type> s("a*b"); + test_type re(s); +} + int main() { test01(); + test02(); return 0; }; diff --git a/libstdc++-v3/testsuite/tr1/7_regular_expressions/basic_regex/ctors/wchar_t/string.cc b/libstdc++-v3/testsuite/tr1/7_regular_expressions/basic_regex/ctors/wchar_t/string.cc index bcedd4966da7..9e6a9adc9a2d 100644 --- a/libstdc++-v3/testsuite/tr1/7_regular_expressions/basic_regex/ctors/wchar_t/string.cc +++ b/libstdc++-v3/testsuite/tr1/7_regular_expressions/basic_regex/ctors/wchar_t/string.cc @@ -25,6 +25,7 @@ #include #include #include +#include // Tests C++ string constructor of the basic_regex class. void test01() @@ -35,9 +36,19 @@ void test01() test_type re(s); } +void test02() +{ + typedef std::tr1::basic_regex test_type; + typedef __gnu_test::tracker_allocator alloc_type; + + std::basic_string, alloc_type> s(L"a*b"); + test_type re(s); +} + int main() { test01(); + test02(); return 0; };