summaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog146
-rw-r--r--libstdc++-v3/include/Makefile.am9
-rw-r--r--libstdc++-v3/include/Makefile.in9
-rw-r--r--libstdc++-v3/include/bits/regex.h2427
-rw-r--r--libstdc++-v3/include/bits/regex_compiler.h1111
-rw-r--r--libstdc++-v3/include/bits/regex_constants.h299
-rw-r--r--libstdc++-v3/include/bits/regex_cursor.h92
-rw-r--r--libstdc++-v3/include/bits/regex_error.h160
-rw-r--r--libstdc++-v3/include/bits/regex_grep_matcher.h131
-rw-r--r--libstdc++-v3/include/bits/regex_grep_matcher.tcc179
-rw-r--r--libstdc++-v3/include/bits/regex_nfa.h403
-rw-r--r--libstdc++-v3/include/bits/regex_nfa.tcc170
-rw-r--r--libstdc++-v3/include/std/regex35
-rw-r--r--libstdc++-v3/testsuite/28_regex/03_requirements/typedefs.cc38
-rw-r--r--libstdc++-v3/testsuite/28_regex/04_header/regex/std_c++0x_neg.cc23
-rw-r--r--libstdc++-v3/testsuite/28_regex/05_constants/error_type.cc54
-rw-r--r--libstdc++-v3/testsuite/28_regex/05_constants/match_flag_type.cc53
-rw-r--r--libstdc++-v3/testsuite/28_regex/05_constants/syntax_option_type.cc51
-rw-r--r--libstdc++-v3/testsuite/28_regex/06_exception_type/regex_error.cc49
-rw-r--r--libstdc++-v3/testsuite/28_regex/07_traits/char/ctor.cc50
-rw-r--r--libstdc++-v3/testsuite/28_regex/07_traits/char/isctype.cc48
-rw-r--r--libstdc++-v3/testsuite/28_regex/07_traits/char/length.cc49
-rw-r--r--libstdc++-v3/testsuite/28_regex/07_traits/char/lookup_classname.cc54
-rw-r--r--libstdc++-v3/testsuite/28_regex/07_traits/char/lookup_collatename.cc50
-rw-r--r--libstdc++-v3/testsuite/28_regex/07_traits/char/transform.cc51
-rw-r--r--libstdc++-v3/testsuite/28_regex/07_traits/char/transform_primary.cc55
-rw-r--r--libstdc++-v3/testsuite/28_regex/07_traits/char/translate.cc49
-rw-r--r--libstdc++-v3/testsuite/28_regex/07_traits/char/translate_nocase.cc46
-rw-r--r--libstdc++-v3/testsuite/28_regex/07_traits/char/value.cc49
-rw-r--r--libstdc++-v3/testsuite/28_regex/07_traits/wchar_t/ctor.cc49
-rw-r--r--libstdc++-v3/testsuite/28_regex/07_traits/wchar_t/length.cc49
-rw-r--r--libstdc++-v3/testsuite/28_regex/07_traits/wchar_t/transform.cc51
-rw-r--r--libstdc++-v3/testsuite/28_regex/07_traits/wchar_t/translate.cc49
-rw-r--r--libstdc++-v3/testsuite/28_regex/07_traits/wchar_t/translate_nocase.cc46
-rw-r--r--libstdc++-v3/testsuite/28_regex/07_traits/wchar_t/value.cc49
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/char/cstring.cc44
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/char/cstring_op.cc43
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/char/moveable.cc50
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/char/pstring.cc43
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/char/range.cc43
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/char/string.cc44
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/char/string_op.cc44
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/wchar_t/cstring.cc44
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/wchar_t/cstring_op.cc44
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/wchar_t/pstring.cc43
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/wchar_t/range.cc44
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/wchar_t/string.cc45
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/wchar_t/string_op.cc45
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/basic/cstring.cc37
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/basic/pstring_char.cc42
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/basic/pstring_wchar_t.cc44
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/basic/string_range_01_02_03.cc52
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/char/cstring.cc42
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/char/cstring_awk.cc37
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/char/cstring_ecma.cc37
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/char/cstring_egrep.cc37
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/char/cstring_grep.cc39
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/char/default.cc47
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/char/range.cc42
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/copy_char.cc45
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/extended/cstring.cc43
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/extended/string_range_01_02_03.cc52
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/move_char.cc49
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/string_char.cc54
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/string_wchar_t.cc56
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/wchar_t/cstring.cc43
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/wchar_t/default.cc48
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/wchar_t/range.cc43
-rw-r--r--libstdc++-v3/testsuite/28_regex/08_basic_regex/regex.cc37
-rw-r--r--libstdc++-v3/testsuite/28_regex/09_sub_match/cast_char.cc49
-rw-r--r--libstdc++-v3/testsuite/28_regex/09_sub_match/cast_wchar_t.cc49
-rw-r--r--libstdc++-v3/testsuite/28_regex/09_sub_match/length.cc49
-rw-r--r--libstdc++-v3/testsuite/28_regex/09_sub_match/typedefs.cc38
-rw-r--r--libstdc++-v3/testsuite/28_regex/10_match_results/ctors/char/default.cc52
-rw-r--r--libstdc++-v3/testsuite/28_regex/10_match_results/ctors/wchar_t/default.cc52
-rw-r--r--libstdc++-v3/testsuite/28_regex/10_match_results/typedefs.cc44
-rw-r--r--libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/basic/string_01.cc63
-rw-r--r--libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/basic/string_range_00_03.cc60
-rw-r--r--libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/basic/string_range_01_03.cc60
-rw-r--r--libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/basic/string_range_02_03.cc61
-rw-r--r--libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/extended/cstring_plus.cc65
-rw-r--r--libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/extended/cstring_questionmark.cc65
-rw-r--r--libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/extended/string_any.cc60
-rw-r--r--libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/extended/string_range_00_03.cc60
-rw-r--r--libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/extended/string_range_01_03.cc60
-rw-r--r--libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/extended/string_range_02_03.cc61
-rw-r--r--libstdc++-v3/testsuite/28_regex/12_iterators/regex_iterator/ctors/char/default.cc35
-rw-r--r--libstdc++-v3/testsuite/28_regex/12_iterators/regex_iterator/ctors/wchar_t/default.cc35
-rw-r--r--libstdc++-v3/testsuite/28_regex/12_iterators/regex_iterator/typedefs.cc40
-rw-r--r--libstdc++-v3/testsuite/28_regex/12_iterators/regex_token_iterator/ctors/char/default.cc35
-rw-r--r--libstdc++-v3/testsuite/28_regex/12_iterators/regex_token_iterator/ctors/wchar_t/default.cc35
-rw-r--r--libstdc++-v3/testsuite/28_regex/12_iterators/regex_token_iterator/typedefs.cc40
92 files changed, 8884 insertions, 19 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index f168df1a820..bf8fd743b63 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,149 @@
+2010-06-25 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+
+ Initial regex implementation.
+
+ * include/std/regex: Modified to use bits/regex_* headers.
+ * include/bits/regex_compiler.h: New file.
+ * include/bits/regex_constants.h: New file.
+ * include/bits/regex_cursor.h: New file.
+ * include/bits/regex_error.h: New file.
+ * include/bits/regex_grep_matcher.h: New file.
+ * include/bits/regex_grep_matcher.tcc: New file.
+ * include/bits/regex.h: New file.
+ * include/bits/regex_nfa.h: New file.
+ * include/bits/regex_nfa.tcc: New file.
+ * include/Makefile.am: Added above new files.
+ * include/Makefile.in: Regenerated.
+ * testsuite/28_regex/02_definitions: New file.
+ * testsuite/28_regex/03_requirements: New file.
+ * testsuite/28_regex/03_requirements/typedefs.cc: New file.
+ * testsuite/28_regex/04_header: New file.
+ * testsuite/28_regex/04_header/regex: New file.
+ * testsuite/28_regex/04_header/regex/std_c++0x_neg.cc: New file.
+ * testsuite/28_regex/05_constants: New file.
+ * testsuite/28_regex/05_constants/error_type.cc: New file.
+ * testsuite/28_regex/05_constants/match_flag_type.cc: New file.
+ * testsuite/28_regex/05_constants/syntax_option_type.cc: New file.
+ * testsuite/28_regex/06_exception_type: New file.
+ * testsuite/28_regex/06_exception_type/regex_error.cc: New file.
+ * testsuite/28_regex/07_traits: New file.
+ * testsuite/28_regex/07_traits/char: New file.
+ * testsuite/28_regex/07_traits/char/ctor.cc: New file.
+ * testsuite/28_regex/07_traits/char/isctype.cc: New file.
+ * testsuite/28_regex/07_traits/char/length.cc: New file.
+ * testsuite/28_regex/07_traits/char/lookup_classname.cc: New file.
+ * testsuite/28_regex/07_traits/char/lookup_collatename.cc: New file.
+ * testsuite/28_regex/07_traits/char/transform.cc: New file.
+ * testsuite/28_regex/07_traits/char/transform_primary.cc: New file.
+ * testsuite/28_regex/07_traits/char/translate.cc: New file.
+ * testsuite/28_regex/07_traits/char/translate_nocase.cc: New file.
+ * testsuite/28_regex/07_traits/char/value.cc: New file.
+ * testsuite/28_regex/07_traits/wchar_t: New file.
+ * testsuite/28_regex/07_traits/wchar_t/ctor.cc: New file.
+ * testsuite/28_regex/07_traits/wchar_t/length.cc: New file.
+ * testsuite/28_regex/07_traits/wchar_t/transform.cc: New file.
+ * testsuite/28_regex/07_traits/wchar_t/translate.cc: New file.
+ * testsuite/28_regex/07_traits/wchar_t/translate_nocase.cc: New file.
+ * testsuite/28_regex/07_traits/wchar_t/value.cc: New file.
+ * testsuite/28_regex/08_basic_regex: New file.
+ * testsuite/28_regex/08_basic_regex/assign: New file.
+ * testsuite/28_regex/08_basic_regex/assign/char: New file.
+ * testsuite/28_regex/08_basic_regex/assign/char/cstring.cc: New file.
+ * testsuite/28_regex/08_basic_regex/assign/char/cstring_op.cc: New file.
+ * testsuite/28_regex/08_basic_regex/assign/char/moveable.cc: New file.
+ * testsuite/28_regex/08_basic_regex/assign/char/pstring.cc: New file.
+ * testsuite/28_regex/08_basic_regex/assign/char/range.cc: New file.
+ * testsuite/28_regex/08_basic_regex/assign/char/string.cc: New file.
+ * testsuite/28_regex/08_basic_regex/assign/char/string_op.cc: New file.
+ * testsuite/28_regex/08_basic_regex/assign/wchar_t: New file.
+ * testsuite/28_regex/08_basic_regex/assign/wchar_t/cstring.cc: New file.
+ * testsuite/28_regex/08_basic_regex/assign/wchar_t/cstring_op.cc: New file.
+ * testsuite/28_regex/08_basic_regex/assign/wchar_t/pstring.cc: New file.
+ * testsuite/28_regex/08_basic_regex/assign/wchar_t/range.cc: New file.
+ * testsuite/28_regex/08_basic_regex/assign/wchar_t/string.cc: New file.
+ * testsuite/28_regex/08_basic_regex/assign/wchar_t/string_op.cc: New file.
+ * testsuite/28_regex/08_basic_regex/ctors: New file.
+ * testsuite/28_regex/08_basic_regex/ctors/basic: New file.
+ * testsuite/28_regex/08_basic_regex/ctors/basic/cstring.cc: New file.
+ * testsuite/28_regex/08_basic_regex/ctors/basic/pstring_char.cc: New file.
+ * testsuite/28_regex/08_basic_regex/ctors/basic/pstring_wchar_t.cc: New file.
+ * testsuite/28_regex/08_basic_regex/ctors/basic/string_range_01_02_03.cc:
+ New file.
+ * testsuite/28_regex/08_basic_regex/ctors/char: New file.
+ * testsuite/28_regex/08_basic_regex/ctors/char/cstring_awk.cc: New file.
+ * testsuite/28_regex/08_basic_regex/ctors/char/cstring.cc: New file.
+ * testsuite/28_regex/08_basic_regex/ctors/char/cstring_ecma.cc: New file.
+ * testsuite/28_regex/08_basic_regex/ctors/char/cstring_egrep.cc: New file.
+ * testsuite/28_regex/08_basic_regex/ctors/char/cstring_grep.cc: New file.
+ * testsuite/28_regex/08_basic_regex/ctors/char/default.cc: New file.
+ * testsuite/28_regex/08_basic_regex/ctors/char/range.cc: New file.
+ * testsuite/28_regex/08_basic_regex/ctors/copy_char.cc: New file.
+ * testsuite/28_regex/08_basic_regex/ctors/extended: New file.
+ * testsuite/28_regex/08_basic_regex/ctors/extended/cstring.cc: New file.
+ * testsuite/28_regex/08_basic_regex/ctors/extended/string_range_01_02_03.cc:
+ New file.
+ * testsuite/28_regex/08_basic_regex/ctors/move_char.cc: New file.
+ * testsuite/28_regex/08_basic_regex/ctors/string_char.cc: New file.
+ * testsuite/28_regex/08_basic_regex/ctors/string_wchar_t.cc: New file.
+ * testsuite/28_regex/08_basic_regex/ctors/wchar_t: New file.
+ * testsuite/28_regex/08_basic_regex/ctors/wchar_t/cstring.cc: New file.
+ * testsuite/28_regex/08_basic_regex/ctors/wchar_t/default.cc: New file.
+ * testsuite/28_regex/08_basic_regex/ctors/wchar_t/range.cc: New file.
+ * testsuite/28_regex/08_basic_regex/regex.cc: New file.
+ * testsuite/28_regex/09_sub_match: New file.
+ * testsuite/28_regex/09_sub_match/cast_char.cc: New file.
+ * testsuite/28_regex/09_sub_match/cast_wchar_t.cc: New file.
+ * testsuite/28_regex/09_sub_match/length.cc: New file.
+ * testsuite/28_regex/09_sub_match/typedefs.cc: New file.
+ * testsuite/28_regex/10_match_results: New file.
+ * testsuite/28_regex/10_match_results/ctors: New file.
+ * testsuite/28_regex/10_match_results/ctors/char: New file.
+ * testsuite/28_regex/10_match_results/ctors/char/default.cc: New file.
+ * testsuite/28_regex/10_match_results/ctors/wchar_t: New file.
+ * testsuite/28_regex/10_match_results/ctors/wchar_t/default.cc: New file.
+ * testsuite/28_regex/10_match_results/typedefs.cc: New file.
+ * testsuite/28_regex/11_algorithms: New file.
+ * testsuite/28_regex/11_algorithms/02_match: New file.
+ * testsuite/28_regex/11_algorithms/02_match/basic: New file.
+ * testsuite/28_regex/11_algorithms/02_match/basic/string_01.cc: New file.
+ * testsuite/28_regex/11_algorithms/02_match/basic/string_range_00_03.cc:
+ New file.
+ * testsuite/28_regex/11_algorithms/02_match/basic/string_range_01_03.cc:
+ New file.
+ * testsuite/28_regex/11_algorithms/02_match/basic/string_range_02_03.cc:
+ New file.
+ * testsuite/28_regex/11_algorithms/02_match/extended: New file.
+ * testsuite/28_regex/11_algorithms/02_match/extended/cstring_plus.cc: New file.
+ * testsuite/28_regex/11_algorithms/02_match/extended/cstring_questionmark.cc:
+ New file.
+ * testsuite/28_regex/11_algorithms/02_match/extended/string_any.cc: New file.
+ * testsuite/28_regex/11_algorithms/02_match/extended/string_range_00_03.cc:
+ New file.
+ * testsuite/28_regex/11_algorithms/02_match/extended/string_range_01_03.cc:
+ New file.
+ * testsuite/28_regex/11_algorithms/02_match/extended/string_range_02_03.cc:
+ New file.
+ * testsuite/28_regex/12_iterators: New file.
+ * testsuite/28_regex/12_iterators/regex_iterator: New file.
+ * testsuite/28_regex/12_iterators/regex_iterator/ctors: New file.
+ * testsuite/28_regex/12_iterators/regex_iterator/ctors/char: New file.
+ * testsuite/28_regex/12_iterators/regex_iterator/ctors/char/default.cc: New
+ file.
+ * testsuite/28_regex/12_iterators/regex_iterator/ctors/wchar_t: New file.
+ * testsuite/28_regex/12_iterators/regex_iterator/ctors/wchar_t/default.cc: New
+ file.
+ * testsuite/28_regex/12_iterators/regex_iterator/typedefs.cc: New file.
+ * testsuite/28_regex/12_iterators/regex_token_iterator: New file.
+ * testsuite/28_regex/12_iterators/regex_token_iterator/ctors: New file.
+ * testsuite/28_regex/12_iterators/regex_token_iterator/ctors/char: New file.
+ * testsuite/28_regex/12_iterators/regex_token_iterator/ctors/char/default.cc:
+ New file.
+ * testsuite/28_regex/12_iterators/regex_token_iterator/ctors/wchar_t: New file.
+ * testsuite/28_regex/12_iterators/regex_token_iterator/ctors/wchar_t/default.cc:
+ New file.
+ * testsuite/28_regex/12_iterators/regex_token_iterator/typedefs.cc: New file.
+ * testsuite/28_regex/13_ecmascript: New file.
+
2010-06-25 Paolo Carlini <paolo.carlini@oracle.com>
* include/profile/impl/profiler_list_to_slist.h: Remove spurious
diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index 1ced7813c1c..6c0230ad292 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -121,6 +121,15 @@ bits_headers = \
${bits_srcdir}/postypes.h \
${bits_srcdir}/random.h \
${bits_srcdir}/random.tcc \
+ ${bits_srcdir}/regex.h \
+ ${bits_srcdir}/regex_compiler.h \
+ ${bits_srcdir}/regex_constants.h \
+ ${bits_srcdir}/regex_cursor.h \
+ ${bits_srcdir}/regex_error.h \
+ ${bits_srcdir}/regex_grep_matcher.h \
+ ${bits_srcdir}/regex_grep_matcher.tcc \
+ ${bits_srcdir}/regex_nfa.h \
+ ${bits_srcdir}/regex_nfa.tcc \
${bits_srcdir}/stream_iterator.h \
${bits_srcdir}/streambuf_iterator.h \
${bits_srcdir}/shared_ptr.h \
diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in
index fd45a43e9da..631561c585e 100644
--- a/libstdc++-v3/include/Makefile.in
+++ b/libstdc++-v3/include/Makefile.in
@@ -361,6 +361,15 @@ bits_headers = \
${bits_srcdir}/postypes.h \
${bits_srcdir}/random.h \
${bits_srcdir}/random.tcc \
+ ${bits_srcdir}/regex.h \
+ ${bits_srcdir}/regex_compiler.h \
+ ${bits_srcdir}/regex_constants.h \
+ ${bits_srcdir}/regex_cursor.h \
+ ${bits_srcdir}/regex_error.h \
+ ${bits_srcdir}/regex_grep_matcher.h \
+ ${bits_srcdir}/regex_grep_matcher.tcc \
+ ${bits_srcdir}/regex_nfa.h \
+ ${bits_srcdir}/regex_nfa.tcc \
${bits_srcdir}/stream_iterator.h \
${bits_srcdir}/streambuf_iterator.h \
${bits_srcdir}/shared_ptr.h \
diff --git a/libstdc++-v3/include/bits/regex.h b/libstdc++-v3/include/bits/regex.h
new file mode 100644
index 00000000000..75c99a747ab
--- /dev/null
+++ b/libstdc++-v3/include/bits/regex.h
@@ -0,0 +1,2427 @@
+// class template regex -*- C++ -*-
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+/**
+ * @file bits/regex
+ * This is an internal header file, included by other library headers.
+ * You should not attempt to use it directly.
+ */
+
+namespace std
+{
+
+/**
+ * @defgroup regex Regular Expressions
+ * A facility for performing regular expression pattern matching.
+ */
+ //@{
+
+ // [7.7] Class regex_traits
+ /**
+ * @brief Describes aspects of a regular expression.
+ *
+ * A regular expression traits class that satisfies the requirements of
+ * section [28.7].
+ *
+ * The class %regex is parameterized around a set of related types and
+ * functions used to complete the definition of its semantics. This class
+ * satisfies the requirements of such a traits class.
+ */
+ template<typename _Ch_type>
+ struct regex_traits
+ {
+ public:
+ typedef _Ch_type char_type;
+ typedef std::basic_string<char_type> string_type;
+ typedef std::locale locale_type;
+ typedef std::ctype_base::mask char_class_type;
+
+ public:
+ /**
+ * @brief Constructs a default traits object.
+ */
+ regex_traits()
+ { }
+
+ /**
+ * @brief Gives the length of a C-style string starting at @p __p.
+ *
+ * @param __p a pointer to the start of a character sequence.
+ *
+ * @returns the number of characters between @p *__p and the first
+ * default-initialized value of type @p char_type. In other words, uses
+ * the C-string algorithm for determining the length of a sequence of
+ * characters.
+ */
+ static std::size_t
+ length(const char_type* __p)
+ { return string_type::traits_type::length(__p); }
+
+ /**
+ * @brief Performs the identity translation.
+ *
+ * @param c A character to the locale-specific character set.
+ *
+ * @returns c.
+ */
+ char_type
+ translate(char_type __c) const
+ { return __c; }
+
+ /**
+ * @brief Translates a character into a case-insensitive equivalent.
+ *
+ * @param c A character to the locale-specific character set.
+ *
+ * @returns the locale-specific lower-case equivalent of c.
+ * @throws std::bad_cast if the imbued locale does not support the ctype
+ * facet.
+ */
+ char_type
+ translate_nocase(char_type __c) const
+ {
+ using std::ctype;
+ using std::use_facet;
+ return use_facet<ctype<char_type> >(_M_locale).tolower(__c);
+ }
+
+ /**
+ * @brief Gets a sort key for a character sequence.
+ *
+ * @param first beginning of the character sequence.
+ * @param last one-past-the-end of the character sequence.
+ *
+ * Returns a sort key for the character sequence designated by the
+ * iterator range [F1, F2) such that if the character sequence [G1, G2)
+ * sorts before the character sequence [H1, H2) then
+ * v.transform(G1, G2) < v.transform(H1, H2).
+ *
+ * What this really does is provide a more efficient way to compare a
+ * string to multiple other strings in locales with fancy collation
+ * rules and equivalence classes.
+ *
+ * @returns a locale-specific sort key equivalent to the input range.
+ *
+ * @throws std::bad_cast if the current locale does not have a collate
+ * facet.
+ */
+ template<typename _Fwd_iter>
+ string_type
+ transform(_Fwd_iter __first, _Fwd_iter __last) const
+ {
+ using std::collate;
+ using std::use_facet;
+ const collate<_Ch_type>& __c(use_facet<
+ collate<_Ch_type> >(_M_locale));
+ string_type __s(__first, __last);
+ return __c.transform(__s.data(), __s.data() + __s.size());
+ }
+
+ /**
+ * @brief Gets a sort key for a character sequence, independant of case.
+ *
+ * @param first beginning of the character sequence.
+ * @param last one-past-the-end of the character sequence.
+ *
+ * Effects: if typeid(use_facet<collate<_Ch_type> >) ==
+ * typeid(collate_byname<_Ch_type>) and the form of the sort key
+ * returned by collate_byname<_Ch_type>::transform(first, last) is known
+ * and can be converted into a primary sort key then returns that key,
+ * otherwise returns an empty string.
+ *
+ * @todo Implement this function.
+ */
+ template<typename _Fwd_iter>
+ string_type
+ transform_primary(_Fwd_iter __first, _Fwd_iter __last) const
+ { return string_type(); }
+
+ /**
+ * @brief Gets a collation element by name.
+ *
+ * @param first beginning of the collation element name.
+ * @param last one-past-the-end of the collation element name.
+ *
+ * @returns a sequence of one or more characters that represents the
+ * collating element consisting of the character sequence designated by
+ * the iterator range [first, last). Returns an empty string if the
+ * character sequence is not a valid collating element.
+ *
+ * @todo Implement this function.
+ */
+ template<typename _Fwd_iter>
+ string_type
+ lookup_collatename(_Fwd_iter __first, _Fwd_iter __last) const
+ { return string_type(); }
+
+ /**
+ * @brief Maps one or more characters to a named character
+ * classification.
+ *
+ * @param first beginning of the character sequence.
+ * @param last one-past-the-end of the character sequence.
+ * @param icase ignores the case of the classification name.
+ *
+ * @returns an unspecified value that represents the character
+ * classification named by the character sequence designated by the
+ * iterator range [first, last). If @p icase is true, the returned mask
+ * identifies the classification regardless of the case of the characters
+ * to be matched (for example, [[:lower:]] is the same as [[:alpha:]]),
+ * otherwise a case-dependant classification is returned. The value
+ * returned shall be independent of the case of the characters in the
+ * character sequence. If the name is not recognized then returns a value
+ * that compares equal to 0.
+ *
+ * At least the following names (or their wide-character equivalent) are
+ * supported.
+ * - d
+ * - w
+ * - s
+ * - alnum
+ * - alpha
+ * - blank
+ * - cntrl
+ * - digit
+ * - graph
+ * - lower
+ * - print
+ * - punct
+ * - space
+ * - upper
+ * - xdigit
+ *
+ * @todo Implement this function.
+ */
+ template<typename _Fwd_iter>
+ char_class_type
+ lookup_classname(_Fwd_iter __first, _Fwd_iter __last,
+ bool __icase = false) const
+ { return 0; }
+
+ /**
+ * @brief Determines if @p c is a member of an identified class.
+ *
+ * @param c a character.
+ * @param f a class type (as returned from lookup_classname).
+ *
+ * @returns true if the character @p c is a member of the classification
+ * represented by @p f, false otherwise.
+ *
+ * @throws std::bad_cast if the current locale does not have a ctype
+ * facet.
+ */
+ bool
+ isctype(_Ch_type __c, char_class_type __f) const;
+
+ /**
+ * @brief Converts a digit to an int.
+ *
+ * @param ch a character representing a digit.
+ * @param radix the radix if the numeric conversion (limited to 8, 10,
+ * or 16).
+ *
+ * @returns the value represented by the digit ch in base radix if the
+ * character ch is a valid digit in base radix; otherwise returns -1.
+ */
+ int
+ value(_Ch_type __ch, int __radix) const;
+
+ /**
+ * @brief Imbues the regex_traits object with a copy of a new locale.
+ *
+ * @param loc A locale.
+ *
+ * @returns a copy of the previous locale in use by the regex_traits
+ * object.
+ *
+ * @note Calling imbue with a different locale than the one currently in
+ * use invalidates all cached data held by *this.
+ */
+ locale_type
+ imbue(locale_type __loc)
+ {
+ std::swap(_M_locale, __loc);
+ return __loc;
+ }
+
+ /**
+ * @brief Gets a copy of the current locale in use by the regex_traits
+ * object.
+ */
+ locale_type
+ getloc() const
+ { return _M_locale; }
+
+ protected:
+ locale_type _M_locale;
+ };
+
+ template<typename _Ch_type>
+ bool
+ regex_traits<_Ch_type>::
+ isctype(_Ch_type __c, char_class_type __f) const
+ {
+ using std::ctype;
+ using std::use_facet;
+ const ctype<_Ch_type>& __ctype(use_facet<
+ ctype<_Ch_type> >(_M_locale));
+
+ if (__ctype.is(__c, __f))
+ return true;
+
+ // special case of underscore in [[:w:]]
+ if (__c == __ctype.widen('_'))
+ {
+ const char __wb[] = "w";
+ char_class_type __wt = this->lookup_classname(__wb,
+ __wb + sizeof(__wb));
+ if (__f | __wt)
+ return true;
+ }
+
+ // special case of [[:space:]] in [[:blank:]]
+ if (__ctype.is(std::ctype_base::space, __c))
+ {
+ const char __bb[] = "blank";
+ char_class_type __bt = this->lookup_classname(__bb,
+ __bb + sizeof(__bb));
+ if (__f | __bt)
+ return true;
+ }
+
+ return false;
+ }
+
+ template<typename _Ch_type>
+ int
+ regex_traits<_Ch_type>::
+ value(_Ch_type __ch, int __radix) const
+ {
+ std::basic_istringstream<_Ch_type> __is(string_type(1, __ch));
+ int __v;
+ if (__radix == 8)
+ __is >> std::oct;
+ else if (__radix == 16)
+ __is >> std::hex;
+ __is >> __v;
+ return __is.fail() ? -1 : __v;
+ }
+
+ // [7.8] Class basic_regex
+ /**
+ * Objects of specializations of this class represent regular expressions
+ * constructed from sequences of character type @p _Ch_type.
+ *
+ * Storage for the regular expression is allocated and deallocated as
+ * necessary by the member functions of this class.
+ */
+ template<typename _Ch_type, typename _Rx_traits = regex_traits<_Ch_type> >
+ class basic_regex
+ {
+ public:
+ // types:
+ typedef _Ch_type value_type;
+ typedef regex_constants::syntax_option_type flag_type;
+ typedef typename _Rx_traits::locale_type locale_type;
+ typedef typename _Rx_traits::string_type string_type;
+
+ /**
+ * @name Constants
+ * std [28.8.1](1)
+ * @todo These should be constexpr.
+ */
+ //@{
+ static const regex_constants::syntax_option_type icase
+ = regex_constants::icase;
+ static const regex_constants::syntax_option_type nosubs
+ = regex_constants::nosubs;
+ static const regex_constants::syntax_option_type optimize
+ = regex_constants::optimize;
+ static const regex_constants::syntax_option_type collate
+ = regex_constants::collate;
+ static const regex_constants::syntax_option_type ECMAScript
+ = regex_constants::ECMAScript;
+ static const regex_constants::syntax_option_type basic
+ = regex_constants::basic;
+ static const regex_constants::syntax_option_type extended
+ = regex_constants::extended;
+ static const regex_constants::syntax_option_type awk
+ = regex_constants::awk;
+ static const regex_constants::syntax_option_type grep
+ = regex_constants::grep;
+ static const regex_constants::syntax_option_type egrep
+ = regex_constants::egrep;
+ //@}
+
+ // [7.8.2] construct/copy/destroy
+ /**
+ * Constructs a basic regular expression that does not match any
+ * character sequence.
+ */
+ basic_regex()
+ : _M_flags(regex_constants::ECMAScript),
+ _M_automaton(__regex::__compile<const _Ch_type*, _Rx_traits>(0, 0,
+ _M_traits, _M_flags))
+ { }
+
+ /**
+ * @brief Constructs a basic regular expression from the sequence
+ * [p, p + char_traits<_Ch_type>::length(p)) interpreted according to the
+ * flags in @p f.
+ *
+ * @param p A pointer to the start of a C-style null-terminated 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.
+ */
+ explicit
+ basic_regex(const _Ch_type* __p,
+ flag_type __f = regex_constants::ECMAScript)
+ : _M_flags(__f),
+ _M_automaton(__regex::__compile(__p, __p + _Rx_traits::length(__p),
+ _M_traits, _M_flags))
+ { }
+
+ /**
+ * @brief Constructs a basic regular expression from the sequence
+ * [p, p + len) interpreted according to the flags in @p f.
+ *
+ * @param p A pointer to the start of a string containing a regular
+ * expression.
+ * @param len The length of the string containing the regular expression.
+ * @param f Flags indicating the syntax rules and options.
+ *
+ * @throws regex_error if @p p is not a valid regular expression.
+ */
+ basic_regex(const _Ch_type* __p, std::size_t __len, flag_type __f)
+ : _M_flags(__f),
+ _M_automaton(__regex::__compile(__p, __p + __len, _M_traits, _M_flags))
+ { }
+
+ /**
+ * @brief Copy-constructs a basic regular expression.
+ *
+ * @param rhs A @p regex object.
+ */
+ basic_regex(const basic_regex& __rhs)
+ : _M_flags(__rhs._M_flags), _M_traits(__rhs._M_traits),
+ _M_automaton(__rhs._M_automaton)
+ { }
+
+ /**
+ * @brief Move-constructs a basic regular expression.
+ *
+ * @param rhs A @p regex object.
+ */
+ basic_regex(const basic_regex&& __rhs)
+ : _M_flags(__rhs._M_flags), _M_traits(__rhs._M_traits),
+ _M_automaton(std::move(__rhs._M_automaton))
+ { }
+
+ /**
+ * @brief Constructs a basic regular expression from the string
+ * @p s interpreted according to the flags in @p f.
+ *
+ * @param s A string containing a regular expression.
+ * @param f Flags indicating the syntax rules and options.
+ *
+ * @throws regex_error if @p s is not a valid regular expression.
+ */
+ template<typename _Ch_traits, typename _Ch_alloc>
+ explicit
+ basic_regex(const std::basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s,
+ flag_type __f = regex_constants::ECMAScript)
+ : _M_flags(__f),
+ _M_automaton(__regex::__compile(__s.begin(), __s.end(),
+ _M_traits, _M_flags))
+ { }
+
+ /**
+ * @brief Constructs a basic regular expression from the range
+ * [first, last) interpreted according to the flags in @p f.
+ *
+ * @param first The start of a range containing a valid regular
+ * expression.
+ * @param last The end of a range containing a valid regular
+ * expression.
+ * @param f The format flags of the regular expression.
+ *
+ * @throws regex_error if @p [first, last) is not a valid regular
+ * expression.
+ */
+ template<typename _InputIterator>
+ basic_regex(_InputIterator __first, _InputIterator __last,
+ flag_type __f = regex_constants::ECMAScript)
+ : _M_flags(__f),
+ _M_automaton(__regex::__compile(__first, __last, _M_traits, _M_flags))
+ { }
+
+ /**
+ * @brief Constructs a basic regular expression from an initializer list.
+ *
+ * @param l The initializer list.
+ * @param f The format flags of the regular expression.
+ *
+ * @throws regex_error if @p l is not a valid regular expression.
+ */
+ basic_regex(initializer_list<_Ch_type> __l,
+ flag_type __f = regex_constants::ECMAScript)
+ : _M_flags(__f),
+ _M_automaton(__regex::__compile(__l.begin(), __l.end(),
+ _M_traits, _M_flags))
+ { }
+
+ /**
+ * @brief Destroys a basic regular expression.
+ */
+ ~basic_regex()
+ { }
+
+ /**
+ * @brief Assigns one regular expression to another.
+ */
+ basic_regex&
+ operator=(const basic_regex& __rhs)
+ { return this->assign(__rhs); }
+
+ /**
+ * @brief Move-assigns one regular expression to another.
+ */
+ basic_regex&
+ operator=(basic_regex&& __rhs)
+ { return this->assign(std::move(__rhs)); }
+
+ /**
+ * @brief Replaces a regular expression with a new one constructed from
+ * a C-style null-terminated string.
+ *
+ * @param A pointer to the start of a null-terminated C-style string
+ * containing a regular expression.
+ */
+ basic_regex&
+ operator=(const _Ch_type* __p)
+ { return this->assign(__p, flags()); }
+
+ /**
+ * @brief Replaces a regular expression with a new one constructed from
+ * a string.
+ *
+ * @param A pointer to a string containing a regular expression.
+ */
+ template<typename _Ch_typeraits, typename _Allocator>
+ basic_regex&
+ operator=(const basic_string<_Ch_type, _Ch_typeraits, _Allocator>& __s)
+ { return this->assign(__s, flags()); }
+
+ // [7.8.3] assign
+ /**
+ * @brief the real assignment operator.
+ *
+ * @param rhs Another regular expression object.
+ */
+ basic_regex&
+ assign(const basic_regex& __rhs)
+ {
+ basic_regex __tmp(__rhs);
+ this->swap(__tmp);
+ return *this;
+ }
+
+ /**
+ * @brief The move-assignment operator.
+ *
+ * @param rhs Another regular expression object.
+ */
+ basic_regex&
+ assign(basic_regex&& __rhs)
+ {
+ basic_regex __tmp(std::move(__rhs));
+ this->swap(__tmp);
+ return *this;
+ }
+
+ /**
+ * @brief Assigns a new regular expression to a regex object from a
+ * C-style null-terminated string containing a regular expression
+ * pattern.
+ *
+ * @param p A pointer to a C-style null-terminated string containing
+ * a regular expression pattern.
+ * @param flags Syntax option flags.
+ *
+ * @throws regex_error if p does not contain a valid regular expression
+ * pattern interpreted according to @p flags. If regex_error is thrown,
+ * *this remains unchanged.
+ */
+ basic_regex&
+ assign(const _Ch_type* __p,
+ flag_type __flags = regex_constants::ECMAScript)
+ { return this->assign(string_type(__p), __flags); }
+
+ /**
+ * @brief Assigns a new regular expression to a regex object from a
+ * C-style string containing a regular expression pattern.
+ *
+ * @param p A pointer to a C-style string containing a
+ * regular expression pattern.
+ * @param len The length of the regular expression pattern string.
+ * @param flags Syntax option flags.
+ *
+ * @throws regex_error if p does not contain a valid regular expression
+ * pattern interpreted according to @p flags. If regex_error is thrown,
+ * *this remains unchanged.
+ */
+ basic_regex&
+ assign(const _Ch_type* __p, std::size_t __len, flag_type __flags)
+ { return this->assign(string_type(__p, __len), __flags); }
+
+ /**
+ * @brief Assigns a new regular expression to a regex object from a
+ * string containing a regular expression pattern.
+ *
+ * @param s A string containing a regular expression pattern.
+ * @param flags Syntax option flags.
+ *
+ * @throws regex_error if p does not contain a valid regular expression
+ * pattern interpreted according to @p flags. If regex_error is thrown,
+ * *this remains unchanged.
+ */
+ template<typename _Ch_typeraits, typename _Allocator>
+ basic_regex&
+ assign(const basic_string<_Ch_type, _Ch_typeraits, _Allocator>& __s,
+ flag_type __f = regex_constants::ECMAScript)
+ {
+ basic_regex __tmp(__s, __f);
+ this->swap(__tmp);
+ return *this;
+ }
+
+ /**
+ * @brief Assigns a new regular expression to a regex object.
+ *
+ * @param first The start of a range containing a valid regular
+ * expression.
+ * @param last The end of a range containing a valid regular
+ * expression.
+ * @param flags Syntax option flags.
+ *
+ * @throws regex_error if p does not contain a valid regular expression
+ * pattern interpreted according to @p flags. If regex_error is thrown,
+ * the object remains unchanged.
+ */
+ template<typename _InputIterator>
+ basic_regex&
+ assign(_InputIterator __first, _InputIterator __last,
+ flag_type __flags = regex_constants::ECMAScript)
+ { return this->assign(string_type(__first, __last), __flags); }
+
+ /**
+ * @brief Assigns a new regular expression to a regex object.
+ *
+ * @param l An initializer list representing a regular expression.
+ * @param flags Syntax option flags.
+ *
+ * @throws regex_error if @p l does not contain a valid regular
+ * expression pattern interpreted according to @p flags. If regex_error
+ * is thrown, the object remains unchanged.
+ */
+ basic_regex&
+ assign(initializer_list<_Ch_type> __l,
+ flag_type __f = regex_constants::ECMAScript)
+ { return this->assign(__l.begin(), __l.end(), __f); }
+
+ // [7.8.4] const operations
+ /**
+ * @brief Gets the number of marked subexpressions within the regular
+ * expression.
+ */
+ unsigned int
+ mark_count() const
+ { return _M_automaton->_M_sub_count() - 1; }
+
+ /**
+ * @brief Gets the flags used to construct the regular expression
+ * or in the last call to assign().
+ */
+ flag_type
+ flags() const
+ { return _M_flags; }
+
+ // [7.8.5] locale
+ /**
+ * @brief Imbues the regular expression object with the given locale.
+ *
+ * @param loc A locale.
+ */
+ locale_type
+ imbue(locale_type __loc)
+ { return _M_traits.imbue(__loc); }
+
+ /**
+ * @brief Gets the locale currently imbued in the regular expression
+ * object.
+ */
+ locale_type
+ getloc() const
+ { return _M_traits.getloc(); }
+
+ // [7.8.6] swap
+ /**
+ * @brief Swaps the contents of two regular expression objects.
+ *
+ * @param rhs Another regular expression object.
+ */
+ void
+ swap(basic_regex& __rhs)
+ {
+ std::swap(_M_flags, __rhs._M_flags);
+ std::swap(_M_traits, __rhs._M_traits);
+ std::swap(_M_automaton, __rhs._M_automaton);
+ }
+
+#ifdef _GLIBCXX_DEBUG
+ void
+ _M_dot(std::ostream& __ostr)
+ { _M_automaton->_M_dot(__ostr); }
+#endif
+
+ const __regex::_AutomatonPtr&
+ _M_get_automaton() const
+ { return _M_automaton; }
+
+ protected:
+ flag_type _M_flags;
+ _Rx_traits _M_traits;
+ __regex::_AutomatonPtr _M_automaton;
+ };
+
+ /** @brief Standard regular expressions. */
+ typedef basic_regex<char> regex;
+#ifdef _GLIBCXX_USE_WCHAR_T
+ /** @brief Standard wide-character regular expressions. */
+ typedef basic_regex<wchar_t> wregex;
+#endif
+
+
+ // [7.8.6] basic_regex swap
+ /**
+ * @brief Swaps the contents of two regular expression objects.
+ * @param lhs First regular expression.
+ * @param rhs Second regular expression.
+ */
+ template<typename _Ch_type, typename _Rx_traits>
+ inline void
+ swap(basic_regex<_Ch_type, _Rx_traits>& __lhs,
+ basic_regex<_Ch_type, _Rx_traits>& __rhs)
+ { __lhs.swap(__rhs); }
+
+
+ // [7.9] Class template sub_match
+ /**
+ * A sequence of characters matched by a particular marked sub-expression.
+ *
+ * An object of this class is essentially a pair of iterators marking a
+ * matched subexpression within a regular expression pattern match. Such
+ * objects can be converted to and compared with std::basic_string objects
+ * of a similar base character type as the pattern matched by the regular
+ * expression.
+ *
+ * The iterators that make up the pair are the usual half-open interval
+ * referencing the actual original pattern matched.
+ */
+ template<typename _BiIter>
+ class sub_match : public std::pair<_BiIter, _BiIter>
+ {
+ public:
+ typedef typename iterator_traits<_BiIter>::value_type value_type;
+ typedef typename iterator_traits<_BiIter>::difference_type
+ difference_type;
+ typedef _BiIter iterator;
+ typedef std::basic_string<value_type> string_type;
+
+ public:
+ bool matched;
+
+ /**
+ * Gets the length of the matching sequence.
+ */
+ difference_type
+ length() const
+ { return this->matched ? std::distance(this->first, this->second) : 0; }
+
+ /**
+ * @brief Gets the matching sequence as a string.
+ *
+ * @returns the matching sequence as a string.
+ *
+ * This is the implicit conversion operator. It is identical to the
+ * str() member function except that it will want to pop up in
+ * unexpected places and cause a great deal of confusion and cursing
+ * from the unwary.
+ */
+ operator string_type() const
+ {
+ return this->matched
+ ? string_type(this->first, this->second)
+ : string_type();
+ }
+
+ /**
+ * @brief Gets the matching sequence as a string.
+ *
+ * @returns the matching sequence as a string.
+ */
+ string_type
+ str() const
+ {
+ return this->matched
+ ? string_type(this->first, this->second)
+ : string_type();
+ }
+
+ /**
+ * @brief Compares this and another matched sequence.
+ *
+ * @param s Another matched sequence to compare to this one.
+ *
+ * @retval <0 this matched sequence will collate before @p s.
+ * @retval =0 this matched sequence is equivalent to @p s.
+ * @retval <0 this matched sequence will collate after @p s.
+ */
+ int
+ compare(const sub_match& __s) const
+ { return this->str().compare(__s.str()); }
+
+ /**
+ * @brief Compares this sub_match to a string.
+ *
+ * @param s A string to compare to this sub_match.
+ *
+ * @retval <0 this matched sequence will collate before @p s.
+ * @retval =0 this matched sequence is equivalent to @p s.
+ * @retval <0 this matched sequence will collate after @p s.
+ */
+ int
+ compare(const string_type& __s) const
+ { return this->str().compare(__s); }
+
+ /**
+ * @brief Compares this sub_match to a C-style string.
+ *
+ * @param s A C-style string to compare to this sub_match.
+ *
+ * @retval <0 this matched sequence will collate before @p s.
+ * @retval =0 this matched sequence is equivalent to @p s.
+ * @retval <0 this matched sequence will collate after @p s.
+ */
+ int
+ compare(const value_type* __s) const
+ { return this->str().compare(__s); }
+ };
+
+
+ /** @brief Standard regex submatch over a C-style null-terminated string. */
+ typedef sub_match<const char*> csub_match;
+ /** @brief Standard regex submatch over a standard string. */
+ typedef sub_match<string::const_iterator> ssub_match;
+#ifdef _GLIBCXX_USE_WCHAR_T
+ /** @brief Regex submatch over a C-style null-terminated wide string. */
+ typedef sub_match<const wchar_t*> wcsub_match;
+ /** @brief Regex submatch over a standard wide string. */
+ typedef sub_match<wstring::const_iterator> wssub_match;
+#endif
+
+ // [7.9.2] sub_match non-member operators
+
+ /**
+ * @brief Tests the equivalence of two regular expression submatches.
+ * @param lhs First regular expression submatch.
+ * @param rhs Second regular expression submatch.
+ * @returns true if @a lhs is equivalent to @a rhs, false otherwise.
+ */
+ template<typename _BiIter>
+ inline bool
+ operator==(const sub_match<_BiIter>& __lhs,
+ const sub_match<_BiIter>& __rhs)
+ { return __lhs.compare(__rhs) == 0; }
+
+ /**
+ * @brief Tests the inequivalence of two regular expression submatches.
+ * @param lhs First regular expression submatch.
+ * @param rhs Second regular expression submatch.
+ * @returns true if @a lhs is not equivalent to @a rhs, false otherwise.
+ */
+ template<typename _BiIter>
+ inline bool
+ operator!=(const sub_match<_BiIter>& __lhs,
+ const sub_match<_BiIter>& __rhs)
+ { return __lhs.compare(__rhs) != 0; }
+
+ /**
+ * @brief Tests the ordering of two regular expression submatches.
+ * @param lhs First regular expression submatch.
+ * @param rhs Second regular expression submatch.
+ * @returns true if @a lhs precedes @a rhs, false otherwise.
+ */
+ template<typename _BiIter>
+ inline bool
+ operator<(const sub_match<_BiIter>& __lhs,
+ const sub_match<_BiIter>& __rhs)
+ { return __lhs.compare(__rhs) < 0; }
+
+ /**
+ * @brief Tests the ordering of two regular expression submatches.
+ * @param lhs First regular expression submatch.
+ * @param rhs Second regular expression submatch.
+ * @returns true if @a lhs does not succeed @a rhs, false otherwise.
+ */
+ template<typename _BiIter>
+ inline bool
+ operator<=(const sub_match<_BiIter>& __lhs,
+ const sub_match<_BiIter>& __rhs)
+ { return __lhs.compare(__rhs) <= 0; }
+
+ /**
+ * @brief Tests the ordering of two regular expression submatches.
+ * @param lhs First regular expression submatch.
+ * @param rhs Second regular expression submatch.
+ * @returns true if @a lhs does not precede @a rhs, false otherwise.
+ */
+ template<typename _BiIter>
+ inline bool
+ operator>=(const sub_match<_BiIter>& __lhs,
+ const sub_match<_BiIter>& __rhs)
+ { return __lhs.compare(__rhs) >= 0; }
+
+ /**
+ * @brief Tests the ordering of two regular expression submatches.
+ * @param lhs First regular expression submatch.
+ * @param rhs Second regular expression submatch.
+ * @returns true if @a lhs succeeds @a rhs, false otherwise.
+ */
+ template<typename _BiIter>
+ inline bool
+ operator>(const sub_match<_BiIter>& __lhs,
+ const sub_match<_BiIter>& __rhs)
+ { return __lhs.compare(__rhs) > 0; }
+
+ /**
+ * @brief Tests the equivalence of a string and a regular expression
+ * submatch.
+ * @param lhs A string.
+ * @param rhs A regular expression submatch.
+ * @returns true if @a lhs is equivalent to @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
+ inline bool
+ operator==(const basic_string<
+ typename iterator_traits<_Bi_iter>::value_type,
+ _Ch_traits, _Ch_alloc>& __lhs,
+ const sub_match<_Bi_iter>& __rhs)
+ { return __lhs == __rhs.str(); }
+
+ /**
+ * @brief Tests the inequivalence of a string and a regular expression
+ * submatch.
+ * @param lhs A string.
+ * @param rhs A regular expression submatch.
+ * @returns true if @a lhs is not equivalent to @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
+ inline bool
+ operator!=(const basic_string<
+ typename iterator_traits<_Bi_iter>::value_type,
+ _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs)
+ { return __lhs != __rhs.str(); }
+
+ /**
+ * @brief Tests the ordering of a string and a regular expression submatch.
+ * @param lhs A string.
+ * @param rhs A regular expression submatch.
+ * @returns true if @a lhs precedes @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
+ inline bool
+ operator<(const basic_string<
+ typename iterator_traits<_Bi_iter>::value_type,
+ _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs)
+ { return __lhs < __rhs.str(); }
+
+ /**
+ * @brief Tests the ordering of a string and a regular expression submatch.
+ * @param lhs A string.
+ * @param rhs A regular expression submatch.
+ * @returns true if @a lhs succeeds @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
+ inline bool
+ operator>(const basic_string<
+ typename iterator_traits<_Bi_iter>::value_type,
+ _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs)
+ { return __lhs > __rhs.str(); }
+
+ /**
+ * @brief Tests the ordering of a string and a regular expression submatch.
+ * @param lhs A string.
+ * @param rhs A regular expression submatch.
+ * @returns true if @a lhs does not precede @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
+ inline bool
+ operator>=(const basic_string<
+ typename iterator_traits<_Bi_iter>::value_type,
+ _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs)
+ { return __lhs >= __rhs.str(); }
+
+ /**
+ * @brief Tests the ordering of a string and a regular expression submatch.
+ * @param lhs A string.
+ * @param rhs A regular expression submatch.
+ * @returns true if @a lhs does not succeed @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
+ inline bool
+ operator<=(const basic_string<
+ typename iterator_traits<_Bi_iter>::value_type,
+ _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs)
+ { return __lhs <= __rhs.str(); }
+
+ /**
+ * @brief Tests the equivalence of a regular expression submatch and a
+ * string.
+ * @param lhs A regular expression submatch.
+ * @param rhs A string.
+ * @returns true if @a lhs is equivalent to @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
+ inline bool
+ operator==(const sub_match<_Bi_iter>& __lhs,
+ const basic_string<
+ typename iterator_traits<_Bi_iter>::value_type,
+ _Ch_traits, _Ch_alloc>& __rhs)
+ { return __lhs.str() == __rhs; }
+
+ /**
+ * @brief Tests the inequivalence of a regular expression submatch and a
+ * string.
+ * @param lhs A regular expression submatch.
+ * @param rhs A string.
+ * @returns true if @a lhs is not equivalent to @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
+ inline bool
+ operator!=(const sub_match<_Bi_iter>& __lhs,
+ const basic_string<
+ typename iterator_traits<_Bi_iter>::value_type,
+ _Ch_traits, _Ch_alloc>& __rhs)
+ { return __lhs.str() != __rhs; }
+
+ /**
+ * @brief Tests the ordering of a regular expression submatch and a string.
+ * @param lhs A regular expression submatch.
+ * @param rhs A string.
+ * @returns true if @a lhs precedes @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc>
+ inline bool
+ operator<(const sub_match<_Bi_iter>& __lhs,
+ const basic_string<
+ typename iterator_traits<_Bi_iter>::value_type,
+ _Ch_traits, _Ch_alloc>& __rhs)
+ { return __lhs.str() < __rhs; }
+
+ /**
+ * @brief Tests the ordering of a regular expression submatch and a string.
+ * @param lhs A regular expression submatch.
+ * @param rhs A string.
+ * @returns true if @a lhs succeeds @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc>
+ inline bool
+ operator>(const sub_match<_Bi_iter>& __lhs,
+ const basic_string<
+ typename iterator_traits<_Bi_iter>::value_type,
+ _Ch_traits, _Ch_alloc>& __rhs)
+ { return __lhs.str() > __rhs; }
+
+ /**
+ * @brief Tests the ordering of a regular expression submatch and a string.
+ * @param lhs A regular expression submatch.
+ * @param rhs A string.
+ * @returns true if @a lhs does not precede @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc>
+ inline bool
+ operator>=(const sub_match<_Bi_iter>& __lhs,
+ const basic_string<
+ typename iterator_traits<_Bi_iter>::value_type,
+ _Ch_traits, _Ch_alloc>& __rhs)
+ { return __lhs.str() >= __rhs; }
+
+ /**
+ * @brief Tests the ordering of a regular expression submatch and a string.
+ * @param lhs A regular expression submatch.
+ * @param rhs A string.
+ * @returns true if @a lhs does not succeed @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc>
+ inline bool
+ operator<=(const sub_match<_Bi_iter>& __lhs,
+ const basic_string<
+ typename iterator_traits<_Bi_iter>::value_type,
+ _Ch_traits, _Ch_alloc>& __rhs)
+ { return __lhs.str() <= __rhs; }
+
+ /**
+ * @brief Tests the equivalence of a C string and a regular expression
+ * submatch.
+ * @param lhs A C string.
+ * @param rhs A regular expression submatch.
+ * @returns true if @a lhs is equivalent to @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter>
+ inline bool
+ operator==(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
+ const sub_match<_Bi_iter>& __rhs)
+ { return __lhs == __rhs.str(); }
+
+ /**
+ * @brief Tests the inequivalence of an iterator value and a regular
+ * expression submatch.
+ * @param lhs A regular expression submatch.
+ * @param rhs A string.
+ * @returns true if @a lhs is not equivalent to @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter>
+ inline bool
+ operator!=(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
+ const sub_match<_Bi_iter>& __rhs)
+ { return __lhs != __rhs.str(); }
+
+ /**
+ * @brief Tests the ordering of a string and a regular expression submatch.
+ * @param lhs A string.
+ * @param rhs A regular expression submatch.
+ * @returns true if @a lhs precedes @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter>
+ inline bool
+ operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
+ const sub_match<_Bi_iter>& __rhs)
+ { return __lhs < __rhs.str(); }
+
+ /**
+ * @brief Tests the ordering of a string and a regular expression submatch.
+ * @param lhs A string.
+ * @param rhs A regular expression submatch.
+ * @returns true if @a lhs succeeds @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter>
+ inline bool
+ operator>(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
+ const sub_match<_Bi_iter>& __rhs)
+ { return __lhs > __rhs.str(); }
+
+ /**
+ * @brief Tests the ordering of a string and a regular expression submatch.
+ * @param lhs A string.
+ * @param rhs A regular expression submatch.
+ * @returns true if @a lhs does not precede @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter>
+ inline bool
+ operator>=(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
+ const sub_match<_Bi_iter>& __rhs)
+ { return __lhs >= __rhs.str(); }
+
+ /**
+ * @brief Tests the ordering of a string and a regular expression submatch.
+ * @param lhs A string.
+ * @param rhs A regular expression submatch.
+ * @returns true if @a lhs does not succeed @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter>
+ inline bool
+ operator<=(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
+ const sub_match<_Bi_iter>& __rhs)
+ { return __lhs <= __rhs.str(); }
+
+ /**
+ * @brief Tests the equivalence of a regular expression submatch and a
+ * string.
+ * @param lhs A regular expression submatch.
+ * @param rhs A pointer to a string?
+ * @returns true if @a lhs is equivalent to @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter>
+ inline bool
+ operator==(const sub_match<_Bi_iter>& __lhs,
+ typename iterator_traits<_Bi_iter>::value_type const* __rhs)
+ { return __lhs.str() == __rhs; }
+
+ /**
+ * @brief Tests the inequivalence of a regular expression submatch and a
+ * string.
+ * @param lhs A regular expression submatch.
+ * @param rhs A pointer to a string.
+ * @returns true if @a lhs is not equivalent to @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter>
+ inline bool
+ operator!=(const sub_match<_Bi_iter>& __lhs,
+ typename iterator_traits<_Bi_iter>::value_type const* __rhs)
+ { return __lhs.str() != __rhs; }
+
+ /**
+ * @brief Tests the ordering of a regular expression submatch and a string.
+ * @param lhs A regular expression submatch.
+ * @param rhs A string.
+ * @returns true if @a lhs precedes @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter>
+ inline bool
+ operator<(const sub_match<_Bi_iter>& __lhs,
+ typename iterator_traits<_Bi_iter>::value_type const* __rhs)
+ { return __lhs.str() < __rhs; }
+
+ /**
+ * @brief Tests the ordering of a regular expression submatch and a string.
+ * @param lhs A regular expression submatch.
+ * @param rhs A string.
+ * @returns true if @a lhs succeeds @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter>
+ inline bool
+ operator>(const sub_match<_Bi_iter>& __lhs,
+ typename iterator_traits<_Bi_iter>::value_type const* __rhs)
+ { return __lhs.str() > __rhs; }
+
+ /**
+ * @brief Tests the ordering of a regular expression submatch and a string.
+ * @param lhs A regular expression submatch.
+ * @param rhs A string.
+ * @returns true if @a lhs does not precede @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter>
+ inline bool
+ operator>=(const sub_match<_Bi_iter>& __lhs,
+ typename iterator_traits<_Bi_iter>::value_type const* __rhs)
+ { return __lhs.str() >= __rhs; }
+
+ /**
+ * @brief Tests the ordering of a regular expression submatch and a string.
+ * @param lhs A regular expression submatch.
+ * @param rhs A string.
+ * @returns true if @a lhs does not succeed @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter>
+ inline bool
+ operator<=(const sub_match<_Bi_iter>& __lhs,
+ typename iterator_traits<_Bi_iter>::value_type const* __rhs)
+ { return __lhs.str() <= __rhs; }
+
+ /**
+ * @brief Tests the equivalence of a string and a regular expression
+ * submatch.
+ * @param lhs A string.
+ * @param rhs A regular expression submatch.
+ * @returns true if @a lhs is equivalent to @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter>
+ inline bool
+ operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
+ const sub_match<_Bi_iter>& __rhs)
+ { return __lhs == __rhs.str(); }
+
+ /**
+ * @brief Tests the inequivalence of a string and a regular expression
+ * submatch.
+ * @param lhs A string.
+ * @param rhs A regular expression submatch.
+ * @returns true if @a lhs is not equivalent to @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter>
+ inline bool
+ operator!=(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
+ const sub_match<_Bi_iter>& __rhs)
+ { return __lhs != __rhs.str(); }
+
+ /**
+ * @brief Tests the ordering of a string and a regular expression submatch.
+ * @param lhs A string.
+ * @param rhs A regular expression submatch.
+ * @returns true if @a lhs precedes @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter>
+ inline bool
+ operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
+ const sub_match<_Bi_iter>& __rhs)
+ { return __lhs < __rhs.str(); }
+
+ /**
+ * @brief Tests the ordering of a string and a regular expression submatch.
+ * @param lhs A string.
+ * @param rhs A regular expression submatch.
+ * @returns true if @a lhs succeeds @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter>
+ inline bool
+ operator>(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
+ const sub_match<_Bi_iter>& __rhs)
+ { return __lhs > __rhs.str(); }
+
+ /**
+ * @brief Tests the ordering of a string and a regular expression submatch.
+ * @param lhs A string.
+ * @param rhs A regular expression submatch.
+ * @returns true if @a lhs does not precede @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter>
+ inline bool
+ operator>=(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
+ const sub_match<_Bi_iter>& __rhs)
+ { return __lhs >= __rhs.str(); }
+
+ /**
+ * @brief Tests the ordering of a string and a regular expression submatch.
+ * @param lhs A string.
+ * @param rhs A regular expression submatch.
+ * @returns true if @a lhs does not succeed @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter>
+ inline bool
+ operator<=(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
+ const sub_match<_Bi_iter>& __rhs)
+ { return __lhs <= __rhs.str(); }
+
+ /**
+ * @brief Tests the equivalence of a regular expression submatch and a
+ * string.
+ * @param lhs A regular expression submatch.
+ * @param rhs A const string reference.
+ * @returns true if @a lhs is equivalent to @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter>
+ inline bool
+ operator==(const sub_match<_Bi_iter>& __lhs,
+ typename iterator_traits<_Bi_iter>::value_type const& __rhs)
+ { return __lhs.str() == __rhs; }
+
+ /**
+ * @brief Tests the inequivalence of a regular expression submatch and a
+ * string.
+ * @param lhs A regular expression submatch.
+ * @param rhs A const string reference.
+ * @returns true if @a lhs is not equivalent to @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter>
+ inline bool
+ operator!=(const sub_match<_Bi_iter>& __lhs,
+ typename iterator_traits<_Bi_iter>::value_type const& __rhs)
+ { return __lhs.str() != __rhs; }
+
+ /**
+ * @brief Tests the ordering of a regular expression submatch and a string.
+ * @param lhs A regular expression submatch.
+ * @param rhs A const string reference.
+ * @returns true if @a lhs precedes @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter>
+ inline bool
+ operator<(const sub_match<_Bi_iter>& __lhs,
+ typename iterator_traits<_Bi_iter>::value_type const& __rhs)
+ { return __lhs.str() < __rhs; }
+
+ /**
+ * @brief Tests the ordering of a regular expression submatch and a string.
+ * @param lhs A regular expression submatch.
+ * @param rhs A const string reference.
+ * @returns true if @a lhs succeeds @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter>
+ inline bool
+ operator>(const sub_match<_Bi_iter>& __lhs,
+ typename iterator_traits<_Bi_iter>::value_type const& __rhs)
+ { return __lhs.str() > __rhs; }
+
+ /**
+ * @brief Tests the ordering of a regular expression submatch and a string.
+ * @param lhs A regular expression submatch.
+ * @param rhs A const string reference.
+ * @returns true if @a lhs does not precede @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter>
+ inline bool
+ operator>=(const sub_match<_Bi_iter>& __lhs,
+ typename iterator_traits<_Bi_iter>::value_type const& __rhs)
+ { return __lhs.str() >= __rhs; }
+
+ /**
+ * @brief Tests the ordering of a regular expression submatch and a string.
+ * @param lhs A regular expression submatch.
+ * @param rhs A const string reference.
+ * @returns true if @a lhs does not succeed @a rhs, false otherwise.
+ */
+ template<typename _Bi_iter>
+ inline bool
+ operator<=(const sub_match<_Bi_iter>& __lhs,
+ typename iterator_traits<_Bi_iter>::value_type const& __rhs)
+ { return __lhs.str() <= __rhs; }
+
+ /**
+ * @brief Inserts a matched string into an output stream.
+ *
+ * @param os The output stream.
+ * @param m A submatch string.
+ *
+ * @returns the output stream with the submatch string inserted.
+ */
+ template<typename _Ch_type, typename _Ch_traits, typename _Bi_iter>
+ inline
+ basic_ostream<_Ch_type, _Ch_traits>&
+ operator<<(basic_ostream<_Ch_type, _Ch_traits>& __os,
+ const sub_match<_Bi_iter>& __m)
+ { return __os << __m.str(); }
+
+ // [7.10] Class template match_results
+
+ /*
+ * Special sub_match object representing an unmatched sub-expression.
+ */
+ template<typename _Bi_iter>
+ inline const sub_match<_Bi_iter>&
+ __unmatched_sub()
+ {
+ static const sub_match<_Bi_iter> __unmatched = sub_match<_Bi_iter>();
+ return __unmatched;
+ }
+
+ /**
+ * @brief The results of a match or search operation.
+ *
+ * A collection of character sequences representing the result of a regular
+ * expression match. Storage for the collection is allocated and freed as
+ * necessary by the member functions of class template match_results.
+ *
+ * This class satisfies the Sequence requirements, with the exception that
+ * only the operations defined for a const-qualified Sequence are supported.
+ *
+ * The sub_match object stored at index 0 represents sub-expression 0, i.e.
+ * the whole match. In this case the %sub_match member matched is always true.
+ * The sub_match object stored at index n denotes what matched the marked
+ * sub-expression n within the matched expression. If the sub-expression n
+ * participated in a regular expression match then the %sub_match member
+ * matched evaluates to true, and members first and second denote the range
+ * of characters [first, second) which formed that match. Otherwise matched
+ * is false, and members first and second point to the end of the sequence
+ * that was searched.
+ *
+ * @nosubgrouping
+ */
+ template<typename _Bi_iter,
+ typename _Allocator = allocator<sub_match<_Bi_iter> > >
+ class match_results
+ : private std::vector<std::sub_match<_Bi_iter>, _Allocator>
+ {
+ private:
+ /*
+ * The vector base is empty if this does not represent a successful match.
+ * Otherwise it contains n+3 elements where n is the number of marked
+ * sub-expressions:
+ * [0] entire match
+ * [1] 1st marked subexpression
+ * ...
+ * [n] nth marked subexpression
+ * [n+1] prefix
+ * [n+2] suffix
+ */
+ typedef std::vector<std::sub_match<_Bi_iter>, _Allocator>
+ _Base_type;
+
+ public:
+ /**
+ * @name 10.? Public Types
+ */
+ //@{
+ typedef sub_match<_Bi_iter> value_type;
+ typedef const value_type& const_reference;
+ typedef const_reference reference;
+ typedef typename _Base_type::const_iterator const_iterator;
+ typedef const_iterator iterator;
+ typedef typename std::iterator_traits<_Bi_iter>::difference_type
+ difference_type;
+ /* TODO: needs allocator_traits */
+ typedef typename _Allocator::size_type size_type;
+ typedef _Allocator allocator_type;
+ typedef typename std::iterator_traits<_Bi_iter>::value_type
+ char_type;
+ typedef std::basic_string<char_type> string_type;
+ //@}
+
+ public:
+ /**
+ * @name 10.1 Construction, Copying, and Destruction
+ */
+ //@{
+
+ /**
+ * @brief Constructs a default %match_results container.
+ * @post size() returns 0 and str() returns an empty string.
+ */
+ explicit
+ match_results(const _Allocator& __a = _Allocator())
+ : _Base_type(__a)
+ { }
+
+ /**
+ * @brief Copy constructs a %match_results.
+ */
+ match_results(const match_results& __rhs)
+ : _Base_type(__rhs)
+ { }
+
+ /**
+ * @brief Assigns rhs to *this.
+ */
+ match_results&
+ operator=(const match_results __rhs)
+ {
+ match_results(__rhs).swap(*this);
+ return *this;
+ }
+
+ /**
+ * @brief Destroys a %match_results object.
+ */
+ ~match_results()
+ { }
+
+ //@}
+
+ /**
+ * @name 10.2 Size
+ */
+ //@{
+
+ /**
+ * @brief Gets the number of matches and submatches.
+ *
+ * The number of matches for a given regular expression will be either 0
+ * if there was no match or mark_count() + 1 if a match was successful.
+ * Some matches may be empty.
+ *
+ * @returns the number of matches found.
+ */
+ size_type
+ size() const
+ {
+ size_type __size = _Base_type::size();
+ return (__size && _Base_type::operator[](0).matched) ? __size - 2 : 0;
+ }
+
+ size_type
+ max_size() const
+ { return _Base_type::max_size(); }
+
+ /**
+ * @brief Indicates if the %match_results contains no results.
+ * @retval true The %match_results object is empty.
+ * @retval false The %match_results object is not empty.
+ */
+ bool
+ empty() const
+ { return _Base_type::empty(); }
+
+ //@}
+
+ /**
+ * @name 10.3 Element Access
+ */
+ //@{
+
+ /**
+ * @brief Gets the length of the indicated submatch.
+ * @param sub indicates the submatch.
+ *
+ * This function returns the length of the indicated submatch, or the
+ * length of the entire match if @p sub is zero (the default).
+ */
+ difference_type
+ length(size_type __sub = 0) const
+ { return this[__sub].length(); }
+
+ /**
+ * @brief Gets the offset of the beginning of the indicated submatch.
+ * @param sub indicates the submatch.
+ *
+ * This function returns the offset from the beginning of the target
+ * sequence to the beginning of the submatch, unless the value of @p sub
+ * is zero (the default), in which case this function returns the offset
+ * from the beginning of the target sequence to the beginning of the
+ * match.
+ *
+ * Returns -1 if @p sub is out of range.
+ */
+ difference_type
+ position(size_type __sub = 0) const
+ {
+ return __sub < size() ? std::distance(this->prefix().first,
+ (*this)[__sub].first) : -1;
+ }
+
+ /**
+ * @brief Gets the match or submatch converted to a string type.
+ * @param sub indicates the submatch.
+ *
+ * This function gets the submatch (or match, if @p sub is zero) extracted
+ * from the target range and converted to the associated string type.
+ */
+ string_type
+ str(size_type __sub = 0) const
+ { return (*this)[__sub].str(); }
+
+ /**
+ * @brief Gets a %sub_match reference for the match or submatch.
+ * @param sub indicates the submatch.
+ *
+ * This function gets a reference to the indicated submatch, or the entire
+ * match if @p sub is zero.
+ *
+ * If @p sub >= size() then this function returns a %sub_match with a
+ * special value indicating no submatch.
+ */
+ const_reference
+ operator[](size_type __sub) const
+ {
+ return __sub < size()
+ ? _Base_type::operator[](__sub)
+ : __unmatched_sub<_Bi_iter>();
+ }
+
+ /**
+ * @brief Gets a %sub_match representing the match prefix.
+ *
+ * This function gets a reference to a %sub_match object representing the
+ * part of the target range between the start of the target range and the
+ * start of the match.
+ */
+ const_reference
+ prefix() const
+ {
+ return !empty()
+ ? _Base_type::operator[](_Base_type::size() - 2)
+ : __unmatched_sub<_Bi_iter>();
+ }
+
+ /**
+ * @brief Gets a %sub_match representing the match suffix.
+ *
+ * This function gets a reference to a %sub_match object representing the
+ * part of the target range between the end of the match and the end of
+ * the target range.
+ */
+ const_reference
+ suffix() const
+ {
+ return !empty()
+ ? _Base_type::operator[](_Base_type::size() - 1)
+ : __unmatched_sub<_Bi_iter>();
+ }
+
+ /**
+ * @brief Gets an iterator to the start of the %sub_match collection.
+ */
+ const_iterator
+ begin() const
+ { return _Base_type::begin(); }
+
+ /**
+ * @brief Gets an iterator to the start of the %sub_match collection.
+ */
+ const_iterator
+ cbegin() const
+ { return _Base_type::cbegin(); }
+
+ /**
+ * @brief Gets an iterator to one-past-the-end of the collection.
+ */
+ const_iterator
+ end() const
+ {
+ return !empty()
+ ? _Base_type::end() - 2
+ : _Base_type::end();
+ }
+
+ /**
+ * @brief Gets an iterator to one-past-the-end of the collection.
+ */
+ const_iterator
+ cend() const
+ {
+ return !empty()
+ ? _Base_type::cend() - 2
+ : _Base_type::cend();
+ }
+
+ //@}
+
+ /**
+ * @name 10.4 Formatting
+ *
+ * These functions perform formatted substitution of the matched character
+ * sequences into their target. The format specifiers and escape sequences
+ * accepted by these functions are determined by their @p flags parameter
+ * as documented above.
+ */
+ //@{
+
+ /**
+ * @todo Implement this function.
+ */
+ template<typename _Out_iter>
+ _Out_iter
+ format(_Out_iter __out, const string_type& __fmt,
+ regex_constants::match_flag_type __flags
+ = regex_constants::format_default) const
+ { return __out; }
+
+ /**
+ * @todo Implement this function.
+ */
+ string_type
+ format(const string_type& __fmt,
+ regex_constants::match_flag_type __flags
+ = regex_constants::format_default) const;
+
+ //@}
+
+ /**
+ * @name 10.5 Allocator
+ */
+ //@{
+
+ /**
+ * @brief Gets a copy of the allocator.
+ */
+ allocator_type
+ get_allocator() const
+ { return _Base_type::get_allocator(); }
+
+ //@}
+
+ /**
+ * @name 10.6 Swap
+ */
+ //@{
+
+ /**
+ * @brief Swaps the contents of two match_results.
+ */
+ void
+ swap(match_results& __that)
+ { _Base_type::swap(__that); }
+ //@}
+
+ private:
+ friend class __regex::_SpecializedResults<_Bi_iter, _Allocator>;
+ };
+
+ typedef match_results<const char*> cmatch;
+ typedef match_results<string::const_iterator> smatch;
+#ifdef _GLIBCXX_USE_WCHAR_T
+ typedef match_results<const wchar_t*> wcmatch;
+ typedef match_results<wstring::const_iterator> wsmatch;
+#endif
+
+ // match_results comparisons
+ /**
+ * @brief Compares two match_results for equality.
+ * @returns true if the two objects refer to the same match,
+ * false otherwise.
+ * @todo Implement this function.
+ */
+ template<typename _Bi_iter, typename _Allocator>
+ inline bool
+ operator==(const match_results<_Bi_iter, _Allocator>& __m1,
+ const match_results<_Bi_iter, _Allocator>& __m2);
+
+ /**
+ * @brief Compares two match_results for inequality.
+ * @returns true if the two objects do not refer to the same match,
+ * false otherwise.
+ */
+ template<typename _Bi_iter, class _Allocator>
+ inline bool
+ operator!=(const match_results<_Bi_iter, _Allocator>& __m1,
+ const match_results<_Bi_iter, _Allocator>& __m2)
+ { return !(__m1 == __m2); }
+
+ // [7.10.6] match_results swap
+ /**
+ * @brief Swaps two match results.
+ * @param lhs A match result.
+ * @param rhs A match result.
+ *
+ * The contents of the two match_results objects are swapped.
+ */
+ template<typename _Bi_iter, typename _Allocator>
+ inline void
+ swap(match_results<_Bi_iter, _Allocator>& __lhs,
+ match_results<_Bi_iter, _Allocator>& __rhs)
+ { __lhs.swap(__rhs); }
+
+ // [7.11.2] Function template regex_match
+ /**
+ * @name Matching, Searching, and Replacing
+ */
+ //@{
+
+ /**
+ * @brief Determines if there is a match between the regular expression @p e
+ * and all of the character sequence [first, last).
+ *
+ * @param s Start of the character sequence to match.
+ * @param e One-past-the-end of the character sequence to match.
+ * @param m The match results.
+ * @param re The regular expression.
+ * @param flags Controls how the regular expression is matched.
+ *
+ * @retval true A match exists.
+ * @retval false Otherwise.
+ *
+ * @throws an exception of type regex_error.
+ *
+ * @todo Implement this function.
+ */
+ template<typename _Bi_iter, typename _Allocator,
+ typename _Ch_type, typename _Rx_traits>
+ bool
+ regex_match(_Bi_iter __s,
+ _Bi_iter __e,
+ match_results<_Bi_iter, _Allocator>& __m,
+ const basic_regex<_Ch_type, _Rx_traits>& __re,
+ regex_constants::match_flag_type __flags
+ = regex_constants::match_default)
+ {
+ __regex::_AutomatonPtr __a = __re._M_get_automaton();
+ __regex::_Automaton::_SizeT __sz = __a->_M_sub_count();
+ __regex::_SpecializedCursor<_Bi_iter> __cs(__s, __e);
+ __regex::_SpecializedResults<_Bi_iter, _Allocator> __r(__sz, __cs, __m);
+ __regex::_Grep_matcher __matcher(__cs, __r, __a, __flags);
+ return __m[0].matched;
+ }
+
+ /**
+ * @brief Indicates if there is a match between the regular expression @p e
+ * and all of the character sequence [first, last).
+ *
+ * @param first Beginning of the character sequence to match.
+ * @param last One-past-the-end of the character sequence to match.
+ * @param re The regular expression.
+ * @param flags Controls how the regular expression is matched.
+ *
+ * @retval true A match exists.
+ * @retval false Otherwise.
+ *
+ * @throws an exception of type regex_error.
+ */
+ template<typename _Bi_iter, typename _Ch_type, typename _Rx_traits>
+ bool
+ regex_match(_Bi_iter __first, _Bi_iter __last,
+ const basic_regex<_Ch_type, _Rx_traits>& __re,
+ regex_constants::match_flag_type __flags
+ = regex_constants::match_default)
+ {
+ match_results<_Bi_iter> __what;
+ return regex_match(__first, __last, __what, __re, __flags);
+ }
+
+ /**
+ * @brief Determines if there is a match between the regular expression @p e
+ * and a C-style null-terminated string.
+ *
+ * @param s The C-style null-terminated string to match.
+ * @param m The match results.
+ * @param re The regular expression.
+ * @param f Controls how the regular expression is matched.
+ *
+ * @retval true A match exists.
+ * @retval false Otherwise.
+ *
+ * @throws an exception of type regex_error.
+ */
+ template<typename _Ch_type, typename _Allocator, typename _Rx_traits>
+ inline bool
+ regex_match(const _Ch_type* __s,
+ match_results<const _Ch_type*, _Allocator>& __m,
+ const basic_regex<_Ch_type, _Rx_traits>& __re,
+ regex_constants::match_flag_type __f
+ = regex_constants::match_default)
+ { return regex_match(__s, __s + _Rx_traits::length(__s), __m, __re, __f); }
+
+ /**
+ * @brief Determines if there is a match between the regular expression @p e
+ * and a string.
+ *
+ * @param s The string to match.
+ * @param m The match results.
+ * @param re The regular expression.
+ * @param flags Controls how the regular expression is matched.
+ *
+ * @retval true A match exists.
+ * @retval false Otherwise.
+ *
+ * @throws an exception of type regex_error.
+ */
+ template<typename _Ch_traits, typename _Ch_alloc,
+ typename _Allocator, typename _Ch_type, typename _Rx_traits>
+ inline bool
+ regex_match(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s,
+ match_results<typename basic_string<_Ch_type,
+ _Ch_traits, _Ch_alloc>::const_iterator, _Allocator>& __m,
+ const basic_regex<_Ch_type, _Rx_traits>& __re,
+ regex_constants::match_flag_type __flags
+ = regex_constants::match_default)
+ { return regex_match(__s.begin(), __s.end(), __m, __re, __flags); }
+
+ /**
+ * @brief Indicates if there is a match between the regular expression @p e
+ * and a C-style null-terminated string.
+ *
+ * @param s The C-style null-terminated string to match.
+ * @param re The regular expression.
+ * @param f Controls how the regular expression is matched.
+ *
+ * @retval true A match exists.
+ * @retval false Otherwise.
+ *
+ * @throws an exception of type regex_error.
+ */
+ template<typename _Ch_type, class _Rx_traits>
+ inline bool
+ regex_match(const _Ch_type* __s,
+ const basic_regex<_Ch_type, _Rx_traits>& __re,
+ regex_constants::match_flag_type __f
+ = regex_constants::match_default)
+ { return regex_match(__s, __s + _Rx_traits::length(__s), __re, __f); }
+
+ /**
+ * @brief Indicates if there is a match between the regular expression @p e
+ * and a string.
+ *
+ * @param s [IN] The string to match.
+ * @param re [IN] The regular expression.
+ * @param flags [IN] Controls how the regular expression is matched.
+ *
+ * @retval true A match exists.
+ * @retval false Otherwise.
+ *
+ * @throws an exception of type regex_error.
+ */
+ template<typename _Ch_traits, typename _Str_allocator,
+ typename _Ch_type, typename _Rx_traits>
+ inline bool
+ regex_match(const basic_string<_Ch_type, _Ch_traits, _Str_allocator>& __s,
+ const basic_regex<_Ch_type, _Rx_traits>& __re,
+ regex_constants::match_flag_type __flags
+ = regex_constants::match_default)
+ { return regex_match(__s.begin(), __s.end(), __re, __flags); }
+
+ // [7.11.3] Function template regex_search
+ /**
+ * Searches for a regular expression within a range.
+ * @param first [IN] The start of the string to search.
+ * @param last [IN] One-past-the-end of the string to search.
+ * @param m [OUT] The match results.
+ * @param re [IN] The regular expression to search for.
+ * @param flags [IN] Search policy flags.
+ * @retval true A match was found within the string.
+ * @retval false No match was found within the string, the content of %m is
+ * undefined.
+ *
+ * @throws an exception of type regex_error.
+ *
+ * @todo Implement this function.
+ */
+ template<typename _Bi_iter, typename _Allocator,
+ typename _Ch_type, typename _Rx_traits>
+ inline bool
+ regex_search(_Bi_iter __first, _Bi_iter __last,
+ match_results<_Bi_iter, _Allocator>& __m,
+ const basic_regex<_Ch_type, _Rx_traits>& __re,
+ regex_constants::match_flag_type __flags
+ = regex_constants::match_default)
+ { return false; }
+
+ /**
+ * Searches for a regular expression within a range.
+ * @param first [IN] The start of the string to search.
+ * @param last [IN] One-past-the-end of the string to search.
+ * @param re [IN] The regular expression to search for.
+ * @param flags [IN] Search policy flags.
+ * @retval true A match was found within the string.
+ * @retval false No match was found within the string.
+ * @doctodo
+ *
+ * @throws an exception of type regex_error.
+ */
+ template<typename _Bi_iter, typename _Ch_type, typename _Rx_traits>
+ inline bool
+ regex_search(_Bi_iter __first, _Bi_iter __last,
+ const basic_regex<_Ch_type, _Rx_traits>& __re,
+ regex_constants::match_flag_type __flags
+ = regex_constants::match_default)
+ {
+ match_results<_Bi_iter> __what;
+ return regex_search(__first, __last, __what, __re, __flags);
+ }
+
+ /**
+ * @brief Searches for a regular expression within a C-string.
+ * @param s [IN] A C-string to search for the regex.
+ * @param m [OUT] The set of regex matches.
+ * @param e [IN] The regex to search for in @p s.
+ * @param f [IN] The search flags.
+ * @retval true A match was found within the string.
+ * @retval false No match was found within the string, the content of %m is
+ * undefined.
+ * @doctodo
+ *
+ * @throws an exception of type regex_error.
+ */
+ template<typename _Ch_type, class _Allocator, class _Rx_traits>
+ inline bool
+ regex_search(const _Ch_type* __s,
+ match_results<const _Ch_type*, _Allocator>& __m,
+ const basic_regex<_Ch_type, _Rx_traits>& __e,
+ regex_constants::match_flag_type __f
+ = regex_constants::match_default)
+ { return regex_search(__s, __s + _Rx_traits::length(__s), __m, __e, __f); }
+
+ /**
+ * @brief Searches for a regular expression within a C-string.
+ * @param s [IN] The C-string to search.
+ * @param e [IN] The regular expression to search for.
+ * @param f [IN] Search policy flags.
+ * @retval true A match was found within the string.
+ * @retval false No match was found within the string.
+ * @doctodo
+ *
+ * @throws an exception of type regex_error.
+ */
+ template<typename _Ch_type, typename _Rx_traits>
+ inline bool
+ regex_search(const _Ch_type* __s,
+ const basic_regex<_Ch_type, _Rx_traits>& __e,
+ regex_constants::match_flag_type __f
+ = regex_constants::match_default)
+ { return regex_search(__s, __s + _Rx_traits::length(__s), __e, __f); }
+
+ /**
+ * @brief Searches for a regular expression within a string.
+ * @param s [IN] The string to search.
+ * @param e [IN] The regular expression to search for.
+ * @param flags [IN] Search policy flags.
+ * @retval true A match was found within the string.
+ * @retval false No match was found within the string.
+ * @doctodo
+ *
+ * @throws an exception of type regex_error.
+ */
+ template<typename _Ch_traits, typename _String_allocator,
+ typename _Ch_type, typename _Rx_traits>
+ inline bool
+ regex_search(const basic_string<_Ch_type, _Ch_traits,
+ _String_allocator>& __s,
+ const basic_regex<_Ch_type, _Rx_traits>& __e,
+ regex_constants::match_flag_type __flags
+ = regex_constants::match_default)
+ { return regex_search(__s.begin(), __s.end(), __e, __flags); }
+
+ /**
+ * @brief Searches for a regular expression within a string.
+ * @param s [IN] A C++ string to search for the regex.
+ * @param m [OUT] The set of regex matches.
+ * @param e [IN] The regex to search for in @p s.
+ * @param f [IN] The search flags.
+ * @retval true A match was found within the string.
+ * @retval false No match was found within the string, the content of %m is
+ * undefined.
+ *
+ * @throws an exception of type regex_error.
+ */
+ template<typename _Ch_traits, typename _Ch_alloc,
+ typename _Allocator, typename _Ch_type,
+ typename _Rx_traits>
+ inline bool
+ regex_search(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s,
+ match_results<typename basic_string<_Ch_type,
+ _Ch_traits, _Ch_alloc>::const_iterator, _Allocator>& __m,
+ const basic_regex<_Ch_type, _Rx_traits>& __e,
+ regex_constants::match_flag_type __f
+ = regex_constants::match_default)
+ { return regex_search(__s.begin(), __s.end(), __m, __e, __f); }
+
+ // std [28.11.4] Function template regex_replace
+ /**
+ * @doctodo
+ * @param out
+ * @param first
+ * @param last
+ * @param e
+ * @param fmt
+ * @param flags
+ *
+ * @returns out
+ * @throws an exception of type regex_error.
+ *
+ * @todo Implement this function.
+ */
+ template<typename _Out_iter, typename _Bi_iter,
+ typename _Rx_traits, typename _Ch_type>
+ inline _Out_iter
+ regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
+ const basic_regex<_Ch_type, _Rx_traits>& __e,
+ const basic_string<_Ch_type>& __fmt,
+ regex_constants::match_flag_type __flags
+ = regex_constants::match_default)
+ { return __out; }
+
+ /**
+ * @doctodo
+ * @param s
+ * @param e
+ * @param fmt
+ * @param flags
+ *
+ * @returns a copy of string @p s with replacements.
+ *
+ * @throws an exception of type regex_error.
+ */
+ template<typename _Rx_traits, typename _Ch_type>
+ inline basic_string<_Ch_type>
+ regex_replace(const basic_string<_Ch_type>& __s,
+ const basic_regex<_Ch_type, _Rx_traits>& __e,
+ const basic_string<_Ch_type>& __fmt,
+ regex_constants::match_flag_type __flags
+ = regex_constants::match_default)
+ {
+ std::string __result;
+ regex_replace(std::back_inserter(__result),
+ __s.begin(), __s.end(), __e, __fmt, __flags);
+ return __result;
+ }
+
+ //@}
+
+ // std [28.12] Class template regex_iterator
+ /**
+ * An iterator adaptor that will provide repeated calls of regex_search over
+ * a range until no more matches remain.
+ */
+ template<typename _Bi_iter,
+ typename _Ch_type = typename iterator_traits<_Bi_iter>::value_type,
+ typename _Rx_traits = regex_traits<_Ch_type> >
+ class regex_iterator
+ {
+ public:
+ typedef basic_regex<_Ch_type, _Rx_traits> regex_type;
+ typedef match_results<_Bi_iter> value_type;
+ typedef std::ptrdiff_t difference_type;
+ typedef const value_type* pointer;
+ typedef const value_type& reference;
+ typedef std::forward_iterator_tag iterator_category;
+
+ public:
+ /**
+ * @brief Provides a singular iterator, useful for indicating
+ * one-past-the-end of a range.
+ * @todo Implement this function.
+ * @doctodo
+ */
+ regex_iterator();
+
+ /**
+ * Constructs a %regex_iterator...
+ * @param a [IN] The start of a text range to search.
+ * @param b [IN] One-past-the-end of the text range to search.
+ * @param re [IN] The regular expression to match.
+ * @param m [IN] Policy flags for match rules.
+ * @todo Implement this function.
+ * @doctodo
+ */
+ regex_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type& __re,
+ regex_constants::match_flag_type __m
+ = regex_constants::match_default);
+
+ /**
+ * Copy constructs a %regex_iterator.
+ * @todo Implement this function.
+ * @doctodo
+ */
+ regex_iterator(const regex_iterator& __rhs);
+
+ /**
+ * @todo Implement this function.
+ * @doctodo
+ */
+ regex_iterator&
+ operator=(const regex_iterator& __rhs);
+
+ /**
+ * @todo Implement this function.
+ * @doctodo
+ */
+ bool
+ operator==(const regex_iterator& __rhs);
+
+ /**
+ * @todo Implement this function.
+ * @doctodo
+ */
+ bool
+ operator!=(const regex_iterator& __rhs);
+
+ /**
+ * @todo Implement this function.
+ * @doctodo
+ */
+ const value_type&
+ operator*();
+
+ /**
+ * @todo Implement this function.
+ * @doctodo
+ */
+ const value_type*
+ operator->();
+
+ /**
+ * @todo Implement this function.
+ * @doctodo
+ */
+ regex_iterator&
+ operator++();
+
+ /**
+ * @todo Implement this function.
+ * @doctodo
+ */
+ regex_iterator
+ operator++(int);
+
+ private:
+ // these members are shown for exposition only:
+ _Bi_iter begin;
+ _Bi_iter end;
+ const regex_type* pregex;
+ regex_constants::match_flag_type flags;
+ match_results<_Bi_iter> match;
+ };
+
+ typedef regex_iterator<const char*> cregex_iterator;
+ typedef regex_iterator<string::const_iterator> sregex_iterator;
+#ifdef _GLIBCXX_USE_WCHAR_T
+ typedef regex_iterator<const wchar_t*> wcregex_iterator;
+ typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
+#endif
+
+ // [7.12.2] Class template regex_token_iterator
+ /**
+ * Iterates over submatches in a range (or @a splits a text string).
+ *
+ * The purpose of this iterator is to enumerate all, or all specified,
+ * matches of a regular expression within a text range. The dereferenced
+ * value of an iterator of this class is a std::sub_match object.
+ */
+ template<typename _Bi_iter,
+ typename _Ch_type = typename iterator_traits<_Bi_iter>::value_type,
+ typename _Rx_traits = regex_traits<_Ch_type> >
+ class regex_token_iterator
+ {
+ public:
+ typedef basic_regex<_Ch_type, _Rx_traits> regex_type;
+ typedef sub_match<_Bi_iter> value_type;
+ typedef std::ptrdiff_t difference_type;
+ typedef const value_type* pointer;
+ typedef const value_type& reference;
+ typedef std::forward_iterator_tag iterator_category;
+
+ public:
+ /**
+ * @brief Default constructs a %regex_token_iterator.
+ * @todo Implement this function.
+ *
+ * A default-constructed %regex_token_iterator is a singular iterator
+ * that will compare equal to the one-past-the-end value for any
+ * iterator of the same type.
+ */
+ regex_token_iterator();
+
+ /**
+ * Constructs a %regex_token_iterator...
+ * @param a [IN] The start of the text to search.
+ * @param b [IN] One-past-the-end of the text to search.
+ * @param re [IN] The regular expression to search for.
+ * @param submatch [IN] Which submatch to return. There are some
+ * special values for this parameter:
+ * - -1 each enumerated subexpression does NOT
+ * match the regular expression (aka field
+ * splitting)
+ * - 0 the entire string matching the
+ * subexpression is returned for each match
+ * within the text.
+ * - >0 enumerates only the indicated
+ * subexpression from a match within the text.
+ * @param m [IN] Policy flags for match rules.
+ *
+ * @todo Implement this function.
+ * @doctodo
+ */
+ regex_token_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type& __re,
+ int __submatch = 0,
+ regex_constants::match_flag_type __m
+ = regex_constants::match_default);
+
+ /**
+ * Constructs a %regex_token_iterator...
+ * @param a [IN] The start of the text to search.
+ * @param b [IN] One-past-the-end of the text to search.
+ * @param re [IN] The regular expression to search for.
+ * @param submatches [IN] A list of subexpressions to return for each
+ * regular expression match within the text.
+ * @param m [IN] Policy flags for match rules.
+ *
+ * @todo Implement this function.
+ * @doctodo
+ */
+ regex_token_iterator(_Bi_iter __a, _Bi_iter __b,
+ const regex_type& __re,
+ const std::vector<int>& __submatches,
+ regex_constants::match_flag_type __m
+ = regex_constants::match_default);
+
+ /**
+ * Constructs a %regex_token_iterator...
+ * @param a [IN] The start of the text to search.
+ * @param b [IN] One-past-the-end of the text to search.
+ * @param re [IN] The regular expression to search for.
+ * @param submatches [IN] A list of subexpressions to return for each
+ * regular expression match within the text.
+ * @param m [IN] Policy flags for match rules.
+
+ * @todo Implement this function.
+ * @doctodo
+ */
+ template<std::size_t _Nm>
+ regex_token_iterator(_Bi_iter __a, _Bi_iter __b,
+ const regex_type& __re,
+ const int (&__submatches)[_Nm],
+ regex_constants::match_flag_type __m
+ = regex_constants::match_default);
+
+ /**
+ * @brief Copy constructs a %regex_token_iterator.
+ * @param rhs [IN] A %regex_token_iterator to copy.
+ * @todo Implement this function.
+ */
+ regex_token_iterator(const regex_token_iterator& __rhs);
+
+ /**
+ * @brief Assigns a %regex_token_iterator to another.
+ * @param rhs [IN] A %regex_token_iterator to copy.
+ * @todo Implement this function.
+ */
+ regex_token_iterator&
+ operator=(const regex_token_iterator& __rhs);
+
+ /**
+ * @brief Compares a %regex_token_iterator to another for equality.
+ * @todo Implement this function.
+ */
+ bool
+ operator==(const regex_token_iterator& __rhs);
+
+ /**
+ * @brief Compares a %regex_token_iterator to another for inequality.
+ * @todo Implement this function.
+ */
+ bool
+ operator!=(const regex_token_iterator& __rhs);
+
+ /**
+ * @brief Dereferences a %regex_token_iterator.
+ * @todo Implement this function.
+ */
+ const value_type&
+ operator*();
+
+ /**
+ * @brief Selects a %regex_token_iterator member.
+ * @todo Implement this function.
+ */
+ const value_type*
+ operator->();
+
+ /**
+ * @brief Increments a %regex_token_iterator.
+ * @todo Implement this function.
+ */
+ regex_token_iterator&
+ operator++();
+
+ /**
+ * @brief Postincrements a %regex_token_iterator.
+ * @todo Implement this function.
+ */
+ regex_token_iterator
+ operator++(int);
+
+ private: // data members for exposition only:
+ typedef regex_iterator<_Bi_iter, _Ch_type, _Rx_traits> position_iterator;
+
+ position_iterator __position;
+ const value_type* __result;
+ value_type __suffix;
+ std::size_t __n;
+ std::vector<int> __subs;
+ };
+
+ /** @brief Token iterator for C-style NULL-terminated strings. */
+ typedef regex_token_iterator<const char*> cregex_token_iterator;
+ /** @brief Token iterator for standard strings. */
+ typedef regex_token_iterator<string::const_iterator> sregex_token_iterator;
+#ifdef _GLIBCXX_USE_WCHAR_T
+ /** @brief Token iterator for C-style NULL-terminated wide strings. */
+ typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
+ /** @brief Token iterator for standard wide-character strings. */
+ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
+#endif
+
+ //@} // group regex
+
+}
+
diff --git a/libstdc++-v3/include/bits/regex_compiler.h b/libstdc++-v3/include/bits/regex_compiler.h
new file mode 100644
index 00000000000..1d12a2cc411
--- /dev/null
+++ b/libstdc++-v3/include/bits/regex_compiler.h
@@ -0,0 +1,1111 @@
+// class template regex -*- C++ -*-
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+/**
+ * @file bits/regex_parser.h
+ * This is an internal header file, included by other library headers.
+ * You should not attempt to use it directly.
+ */
+
+namespace std
+{
+namespace __regex
+{
+ struct _Scanner_base
+ {
+ typedef unsigned int _StateT; // FIXME: replace these constanst with constexpr
+
+ static const _StateT _S_state_at_start = 1 << 0;
+ static const _StateT _S_state_in_brace = 1 << 2;
+ static const _StateT _S_state_in_bracket = 1 << 3;
+ };
+
+ //
+ // @brief Scans an input range for regex tokens.
+ //
+ // The %_Scanner class interprets the regular expression pattern in the input
+ // range passed to its constructor as a sequence of parse tokens passed to
+ // the regular expression compiler. The sequence of tokens provided depends
+ // on the flag settings passed to the constructor: different regular
+ // expression gramars will interpret the same input pattern in syntactically
+ // different ways.
+ //
+ template<typename _InputIterator>
+ class _Scanner: public _Scanner_base
+ {
+ public:
+ typedef _InputIterator _IteratorT;
+ typedef typename std::iterator_traits<_IteratorT>::value_type _CharT;
+ typedef std::basic_string<_CharT> _StringT;
+ typedef regex_constants::syntax_option_type _FlagT;
+ typedef const std::ctype<_CharT> _CtypeT;
+
+ // Token types returned from the scanner.
+ enum _TokenT
+ {
+ _S_token_anychar,
+ _S_token_backref,
+ _S_token_bracket_begin,
+ _S_token_bracket_end,
+ _S_token_inverse_class,
+ _S_token_char_class_name,
+ _S_token_closure0,
+ _S_token_closure1,
+ _S_token_collelem_multi,
+ _S_token_collelem_single,
+ _S_token_collsymbol,
+ _S_token_comma,
+ _S_token_dash,
+ _S_token_dup_count,
+ _S_token_eof,
+ _S_token_equiv_class_name,
+ _S_token_interval_begin,
+ _S_token_interval_end,
+ _S_token_line_begin,
+ _S_token_line_end,
+ _S_token_opt,
+ _S_token_or,
+ _S_token_ord_char,
+ _S_token_quoted_char,
+ _S_token_subexpr_begin,
+ _S_token_subexpr_end,
+ _S_token_word_begin,
+ _S_token_word_end,
+ _S_token_unknown
+ };
+
+ public:
+ _Scanner(_IteratorT __begin, _IteratorT __end, _FlagT __flags,
+ std::locale __loc)
+ : _M_current(__begin) , _M_end(__end) , _M_flags(__flags),
+ _M_ctype(std::use_facet<_CtypeT>(__loc)), _M_state(_S_state_at_start)
+ { _M_advance(); }
+
+ void
+ _M_advance();
+
+ _TokenT
+ _M_token() const
+ { return _M_curToken; }
+
+ const _StringT&
+ _M_value() const
+ { return _M_curValue; }
+
+#ifdef _GLIBCXX_DEBUG
+ std::ostream&
+ _M_print(std::ostream&);
+#endif
+
+ private:
+ void
+ _M_eat_escape();
+
+ void
+ _M_scan_in_brace();
+
+ void
+ _M_scan_in_bracket();
+
+ void
+ _M_eat_charclass();
+
+ void
+ _M_eat_equivclass();
+
+ void
+ _M_eat_collsymbol();
+
+ private:
+ _IteratorT _M_current;
+ _IteratorT _M_end;
+ _FlagT _M_flags;
+ _CtypeT& _M_ctype;
+ _TokenT _M_curToken;
+ _StringT _M_curValue;
+ _StateT _M_state;
+ };
+
+ template<typename _InputIterator>
+ void
+ _Scanner<_InputIterator>::
+ _M_advance()
+ {
+ if (_M_current == _M_end)
+ {
+ _M_curToken = _S_token_eof;
+ return;
+ }
+
+ _CharT __c = *_M_current;
+ if (_M_state & _S_state_in_bracket)
+ {
+ _M_scan_in_bracket();
+ return;
+ }
+ if (_M_state & _S_state_in_brace)
+ {
+ _M_scan_in_brace();
+ return;
+ }
+ else if (_M_state & _S_state_at_start && __c == _M_ctype.widen('^'))
+ {
+ _M_curToken = _S_token_line_begin;
+ ++_M_current;
+ return;
+ }
+ else if (__c == _M_ctype.widen('$'))
+ {
+ _M_curToken = _S_token_line_end;
+ ++_M_current;
+ return;
+ }
+ else if (__c == _M_ctype.widen('.'))
+ {
+ _M_curToken = _S_token_anychar;
+ ++_M_current;
+ return;
+ }
+ else if (__c == _M_ctype.widen('*'))
+ {
+ _M_curToken = _S_token_closure0;
+ ++_M_current;
+ return;
+ }
+ else if (__c == _M_ctype.widen('+'))
+ {
+ _M_curToken = _S_token_closure1;
+ ++_M_current;
+ return;
+ }
+ else if (__c == _M_ctype.widen('|'))
+ {
+ _M_curToken = _S_token_or;
+ ++_M_current;
+ return;
+ }
+ else if (__c == _M_ctype.widen('['))
+ {
+ _M_curToken = _S_token_bracket_begin;
+ _M_state |= (_S_state_in_bracket | _S_state_at_start);
+ ++_M_current;
+ return;
+ }
+ else if (__c == _M_ctype.widen('\\'))
+ {
+ _M_eat_escape();
+ return;
+ }
+ else if (!(_M_flags & (regex_constants::basic | regex_constants::grep)))
+ {
+ if (__c == _M_ctype.widen('('))
+ {
+ _M_curToken = _S_token_subexpr_begin;
+ ++_M_current;
+ return;
+ }
+ else if (__c == _M_ctype.widen(')'))
+ {
+ _M_curToken = _S_token_subexpr_end;
+ ++_M_current;
+ return;
+ }
+ else if (__c == _M_ctype.widen('{'))
+ {
+ _M_curToken = _S_token_interval_begin;
+ _M_state |= _S_state_in_brace;
+ ++_M_current;
+ return;
+ }
+ }
+
+ _M_curToken = _S_token_ord_char;
+ _M_curValue.assign(1, __c);
+ ++_M_current;
+ }
+
+
+ template<typename _InputIterator>
+ void
+ _Scanner<_InputIterator>::
+ _M_scan_in_brace()
+ {
+ if (_M_ctype.is(_CtypeT::digit, *_M_current))
+ {
+ _M_curToken = _S_token_dup_count;
+ _M_curValue.assign(1, *_M_current);
+ ++_M_current;
+ while (_M_current != _M_end && _M_ctype.is(_CtypeT::digit, *_M_current))
+ {
+ _M_curValue += *_M_current;
+ ++_M_current;
+ }
+ return;
+ }
+ else if (*_M_current == _M_ctype.widen(','))
+ {
+ _M_curToken = _S_token_comma;
+ ++_M_current;
+ return;
+ }
+ if (_M_flags & (regex_constants::basic | regex_constants::grep))
+ {
+ if (*_M_current == _M_ctype.widen('\\'))
+ { _M_eat_escape(); }
+ }
+ else
+ {
+ if (*_M_current == _M_ctype.widen('}'))
+ {
+ _M_curToken = _S_token_interval_end;
+ _M_state &= ~_S_state_in_brace;
+ ++_M_current;
+ return;
+ }
+ }
+ }
+
+ template<typename _InputIterator>
+ void
+ _Scanner<_InputIterator>::
+ _M_scan_in_bracket()
+ {
+ if (_M_state & _S_state_at_start && *_M_current == _M_ctype.widen('^'))
+ {
+ _M_curToken = _S_token_inverse_class;
+ _M_state &= ~_S_state_at_start;
+ ++_M_current;
+ return;
+ }
+ else if (*_M_current == _M_ctype.widen('['))
+ {
+ ++_M_current;
+ if (_M_current == _M_end)
+ {
+ _M_curToken = _S_token_eof;
+ return;
+ }
+
+ if (*_M_current == _M_ctype.widen('.'))
+ {
+ _M_curToken = _S_token_collsymbol;
+ _M_eat_collsymbol();
+ return;
+ }
+ else if (*_M_current == _M_ctype.widen(':'))
+ {
+ _M_curToken = _S_token_char_class_name;
+ _M_eat_charclass();
+ return;
+ }
+ else if (*_M_current == _M_ctype.widen('='))
+ {
+ _M_curToken = _S_token_equiv_class_name;
+ _M_eat_equivclass();
+ return;
+ }
+ }
+ else if (*_M_current == _M_ctype.widen('-'))
+ {
+ _M_curToken = _S_token_dash;
+ ++_M_current;
+ return;
+ }
+ else if (*_M_current == _M_ctype.widen(']'))
+ {
+ if (!(_M_flags & regex_constants::ECMAScript)
+ || !(_M_state & _S_state_at_start))
+ {
+ // special case: only if _not_ chr first after '[' or '[^' and if not
+ // ECMAscript
+ _M_curToken = _S_token_bracket_end;
+ ++_M_current;
+ return;
+ }
+ }
+ _M_curToken = _S_token_collelem_single;
+ _M_curValue.assign(1, *_M_current);
+ ++_M_current;
+ }
+
+ template<typename _InputIterator>
+ void
+ _Scanner<_InputIterator>::
+ _M_eat_escape()
+ {
+ ++_M_current;
+ if (_M_current == _M_end)
+ {
+ _M_curToken = _S_token_eof;
+ return;
+ }
+ _CharT __c = *_M_current;
+ ++_M_current;
+
+ if (__c == _M_ctype.widen('('))
+ {
+ if (!(_M_flags & (regex_constants::basic | regex_constants::grep)))
+ {
+ _M_curToken = _S_token_ord_char;
+ _M_curValue.assign(1, __c);
+ }
+ else
+ {
+ _M_curToken = _S_token_subexpr_begin;
+ }
+ }
+ else if (__c == _M_ctype.widen(')'))
+ {
+ if (!(_M_flags & (regex_constants::basic | regex_constants::grep)))
+ {
+ _M_curToken = _S_token_ord_char;
+ _M_curValue.assign(1, __c);
+ }
+ else
+ {
+ _M_curToken = _S_token_subexpr_end;
+ }
+ }
+ else if (__c == _M_ctype.widen('{'))
+ {
+ if (!(_M_flags & (regex_constants::basic | regex_constants::grep)))
+ {
+ _M_curToken = _S_token_ord_char;
+ _M_curValue.assign(1, __c);
+ }
+ else
+ {
+ _M_curToken = _S_token_interval_begin;
+ _M_state |= _S_state_in_brace;
+ }
+ }
+ else if (__c == _M_ctype.widen('}'))
+ {
+ if (!(_M_flags & (regex_constants::basic | regex_constants::grep)))
+ {
+ _M_curToken = _S_token_ord_char;
+ _M_curValue.assign(1, __c);
+ }
+ else
+ {
+ if (!(_M_state && _S_state_in_brace))
+ __throw_regex_error(regex_constants::error_badbrace);
+ _M_state &= ~_S_state_in_brace;
+ _M_curToken = _S_token_interval_end;
+ }
+ }
+ else if (__c == _M_ctype.widen('x'))
+ {
+ ++_M_current;
+ if (_M_current == _M_end)
+ {
+ _M_curToken = _S_token_eof;
+ return;
+ }
+ if (_M_ctype.is(_CtypeT::digit, *_M_current))
+ {
+ _M_curValue.assign(1, *_M_current);
+ ++_M_current;
+ if (_M_current == _M_end)
+ {
+ _M_curToken = _S_token_eof;
+ return;
+ }
+ if (_M_ctype.is(_CtypeT::digit, *_M_current))
+ {
+ _M_curValue += *_M_current;
+ ++_M_current;
+ return;
+ }
+ }
+ }
+ else if (__c == _M_ctype.widen('^')
+ || __c == _M_ctype.widen('.')
+ || __c == _M_ctype.widen('*')
+ || __c == _M_ctype.widen('$')
+ || __c == _M_ctype.widen('\\'))
+ {
+ _M_curToken = _S_token_ord_char;
+ _M_curValue.assign(1, __c);
+ }
+ else if (_M_ctype.is(_CtypeT::digit, __c))
+ {
+ _M_curToken = _S_token_backref;
+ _M_curValue.assign(1, __c);
+ }
+ else
+ {
+ __throw_regex_error(regex_constants::error_escape);
+ }
+ }
+
+
+ // Eats a character class or throwns an exception.
+ // current point to ':' delimiter on entry, char after ']' on return
+ template<typename _InputIterator>
+ void
+ _Scanner<_InputIterator>::
+ _M_eat_charclass()
+ {
+ ++_M_current; // skip ':'
+ if (_M_current == _M_end)
+ __throw_regex_error(regex_constants::error_ctype);
+ for (_M_curValue.clear();
+ _M_current != _M_end && *_M_current != _M_ctype.widen(':');
+ ++_M_current)
+ _M_curValue += *_M_current;
+ if (_M_current == _M_end)
+ __throw_regex_error(regex_constants::error_ctype);
+ ++_M_current; // skip ':'
+ if (*_M_current != _M_ctype.widen(']'))
+ __throw_regex_error(regex_constants::error_ctype);
+ ++_M_current; // skip ']'
+ }
+
+
+ template<typename _InputIterator>
+ void
+ _Scanner<_InputIterator>::
+ _M_eat_equivclass()
+ {
+ ++_M_current; // skip '='
+ if (_M_current == _M_end)
+ __throw_regex_error(regex_constants::error_collate);
+ for (_M_curValue.clear();
+ _M_current != _M_end && *_M_current != _M_ctype.widen('=');
+ ++_M_current)
+ _M_curValue += *_M_current;
+ if (_M_current == _M_end)
+ __throw_regex_error(regex_constants::error_collate);
+ ++_M_current; // skip '='
+ if (*_M_current != _M_ctype.widen(']'))
+ __throw_regex_error(regex_constants::error_collate);
+ ++_M_current; // skip ']'
+ }
+
+
+ template<typename _InputIterator>
+ void
+ _Scanner<_InputIterator>::
+ _M_eat_collsymbol()
+ {
+ ++_M_current; // skip '.'
+ if (_M_current == _M_end)
+ __throw_regex_error(regex_constants::error_collate);
+ for (_M_curValue.clear();
+ _M_current != _M_end && *_M_current != _M_ctype.widen('.');
+ ++_M_current)
+ _M_curValue += *_M_current;
+ if (_M_current == _M_end)
+ __throw_regex_error(regex_constants::error_collate);
+ ++_M_current; // skip '.'
+ if (*_M_current != _M_ctype.widen(']'))
+ __throw_regex_error(regex_constants::error_collate);
+ ++_M_current; // skip ']'
+ }
+
+#ifdef _GLIBCXX_DEBUG
+ template<typename _InputIterator>
+ std::ostream&
+ _Scanner<_InputIterator>::
+ _M_print(std::ostream& ostr)
+ {
+ switch (_M_curToken)
+ {
+ case _S_token_anychar:
+ ostr << "any-character\n";
+ break;
+ case _S_token_backref:
+ ostr << "backref\n";
+ break;
+ case _S_token_bracket_begin:
+ ostr << "bracket-begin\n";
+ break;
+ case _S_token_bracket_end:
+ ostr << "bracket-end\n";
+ break;
+ case _S_token_char_class_name:
+ ostr << "char-class-name \"" << _M_curValue << "\"\n";
+ break;
+ case _S_token_closure0:
+ ostr << "closure0\n";
+ break;
+ case _S_token_closure1:
+ ostr << "closure1\n";
+ break;
+ case _S_token_collelem_multi:
+ ostr << "coll-elem-multi \"" << _M_curValue << "\"\n";
+ break;
+ case _S_token_collelem_single:
+ ostr << "coll-elem-single \"" << _M_curValue << "\"\n";
+ break;
+ case _S_token_collsymbol:
+ ostr << "collsymbol \"" << _M_curValue << "\"\n";
+ break;
+ case _S_token_comma:
+ ostr << "comma\n";
+ break;
+ case _S_token_dash:
+ ostr << "dash\n";
+ break;
+ case _S_token_dup_count:
+ ostr << "dup count: " << _M_curValue << "\n";
+ break;
+ case _S_token_eof:
+ ostr << "EOF\n";
+ break;
+ case _S_token_equiv_class_name:
+ ostr << "equiv-class-name \"" << _M_curValue << "\"\n";
+ break;
+ case _S_token_interval_begin:
+ ostr << "interval begin\n";
+ break;
+ case _S_token_interval_end:
+ ostr << "interval end\n";
+ break;
+ case _S_token_line_begin:
+ ostr << "line begin\n";
+ break;
+ case _S_token_line_end:
+ ostr << "line end\n";
+ break;
+ case _S_token_opt:
+ ostr << "opt\n";
+ break;
+ case _S_token_or:
+ ostr << "or\n";
+ break;
+ case _S_token_ord_char:
+ ostr << "ordinary character: \"" << _M_value() << "\"\n";
+ break;
+ case _S_token_quoted_char:
+ ostr << "quoted char\n";
+ break;
+ case _S_token_subexpr_begin:
+ ostr << "subexpr begin\n";
+ break;
+ case _S_token_subexpr_end:
+ ostr << "subexpr end\n";
+ break;
+ case _S_token_word_begin:
+ ostr << "word begin\n";
+ break;
+ case _S_token_word_end:
+ ostr << "word end\n";
+ break;
+ case _S_token_unknown:
+ ostr << "-- unknown token --\n";
+ break;
+ }
+ return ostr;
+ }
+#endif
+
+ // Builds an NFA from an input iterator interval.
+ template<typename _InIter, typename _TraitsT>
+ class _Compiler
+ {
+ public:
+ typedef _InIter _IterT;
+ typedef typename std::iterator_traits<_InIter>::value_type _CharT;
+ typedef std::basic_string<_CharT> _StringT;
+ typedef regex_constants::syntax_option_type _FlagT;
+
+ public:
+ _Compiler(const _InIter& __b, const _InIter& __e,
+ _TraitsT& __traits, _FlagT __flags);
+
+ const _Nfa&
+ _M_nfa() const
+ { return _M_state_store; }
+
+ private:
+ typedef _Scanner<_InIter> _ScannerT;
+ typedef typename _ScannerT::_TokenT _TokenT;
+ typedef std::stack<_StateSeq, std::vector<_StateSeq> > _StackT;
+ typedef _RangeMatcher<_InIter, _TraitsT> _RMatcherT;
+
+ // accepts a specific token or returns false.
+ bool
+ _M_match_token(_TokenT token);
+
+ void
+ _M_disjunction();
+
+ bool
+ _M_alternative();
+
+ bool
+ _M_term();
+
+ bool
+ _M_assertion();
+
+ bool
+ _M_quantifier();
+
+ bool
+ _M_atom();
+
+ bool
+ _M_bracket_expression();
+
+ bool
+ _M_bracket_list(_RMatcherT& __matcher);
+
+ bool
+ _M_follow_list(_RMatcherT& __matcher);
+
+ bool
+ _M_follow_list2(_RMatcherT& __matcher);
+
+ bool
+ _M_expression_term(_RMatcherT& __matcher);
+
+ bool
+ _M_range_expression(_RMatcherT& __matcher);
+
+ bool
+ _M_start_range(_RMatcherT& __matcher);
+
+ bool
+ _M_collating_symbol(_RMatcherT& __matcher);
+
+ bool
+ _M_equivalence_class(_RMatcherT& __matcher);
+
+ bool
+ _M_character_class(_RMatcherT& __matcher);
+
+ int
+ _M_cur_int_value(int __radix);
+
+ private:
+ _TraitsT& _M_traits;
+ _ScannerT _M_scanner;
+ _StringT _M_cur_value;
+ _Nfa _M_state_store;
+ _StackT _M_stack;
+ };
+
+ template<typename _InIter, typename _TraitsT>
+ _Compiler<_InIter, _TraitsT>::
+ _Compiler(const _InIter& __b, const _InIter& __e, _TraitsT& __traits,
+ _Compiler<_InIter, _TraitsT>::_FlagT __flags)
+ : _M_traits(__traits), _M_scanner(__b, __e, __flags, _M_traits.getloc()),
+ _M_state_store(__flags)
+ {
+ using std::bind;
+ using std::placeholders::_1;
+ using std::placeholders::_2;
+ typedef _StartTagger<_InIter, _TraitsT> _Start;
+ typedef _EndTagger<_InIter, _TraitsT> _End;
+
+ _StateSeq __r(_M_state_store,
+ _M_state_store._M_insert_subexpr_begin(
+ bind(_Start(0), _1, _2)));
+ _M_disjunction();
+ if (!_M_stack.empty())
+ {
+ __r._M_append(_M_stack.top());
+ _M_stack.pop();
+ }
+ __r._M_append(_M_state_store._M_insert_subexpr_end(0,
+ bind(_End(0), _1, _2)));
+ __r._M_append(_M_state_store._M_insert_accept());
+ }
+
+ template<typename _InIter, typename _TraitsT>
+ bool
+ _Compiler<_InIter, _TraitsT>::
+ _M_match_token(_Compiler<_InIter, _TraitsT>::_TokenT token)
+ {
+ if (token == _M_scanner._M_token())
+ {
+ _M_cur_value = _M_scanner._M_value();
+ _M_scanner._M_advance();
+ return true;
+ }
+ return false;
+ }
+
+ template<typename _InIter, typename _TraitsT>
+ void
+ _Compiler<_InIter, _TraitsT>::
+ _M_disjunction()
+ {
+ this->_M_alternative();
+ if (_M_match_token(_ScannerT::_S_token_or))
+ {
+ _StateSeq __alt1 = _M_stack.top(); _M_stack.pop();
+ this->_M_disjunction();
+ _StateSeq __alt2 = _M_stack.top(); _M_stack.pop();
+ _M_stack.push(_StateSeq(__alt1, __alt2));
+ }
+ }
+
+ template<typename _InIter, typename _TraitsT>
+ bool
+ _Compiler<_InIter, _TraitsT>::
+ _M_alternative()
+ {
+ if (this->_M_term())
+ {
+ _StateSeq __re = _M_stack.top(); _M_stack.pop();
+ this->_M_alternative();
+ if (!_M_stack.empty())
+ {
+ __re._M_append(_M_stack.top());
+ _M_stack.pop();
+ }
+ _M_stack.push(__re);
+ return true;
+ }
+ return false;
+ }
+
+ template<typename _InIter, typename _TraitsT>
+ bool
+ _Compiler<_InIter, _TraitsT>::
+ _M_term()
+ {
+ if (this->_M_assertion())
+ return true;
+ if (this->_M_atom())
+ {
+ this->_M_quantifier();
+ return true;
+ }
+ return false;
+ }
+
+ template<typename _InIter, typename _TraitsT>
+ bool
+ _Compiler<_InIter, _TraitsT>::
+ _M_assertion()
+ {
+ if (_M_match_token(_ScannerT::_S_token_line_begin))
+ {
+ // __m.push(_Matcher::_S_opcode_line_begin);
+ return true;
+ }
+ if (_M_match_token(_ScannerT::_S_token_line_end))
+ {
+ // __m.push(_Matcher::_S_opcode_line_end);
+ return true;
+ }
+ if (_M_match_token(_ScannerT::_S_token_word_begin))
+ {
+ // __m.push(_Matcher::_S_opcode_word_begin);
+ return true;
+ }
+ if (_M_match_token(_ScannerT::_S_token_word_end))
+ {
+ // __m.push(_Matcher::_S_opcode_word_end);
+ return true;
+ }
+ return false;
+ }
+
+ template<typename _InIter, typename _TraitsT>
+ bool
+ _Compiler<_InIter, _TraitsT>::
+ _M_quantifier()
+ {
+ if (_M_match_token(_ScannerT::_S_token_closure0))
+ {
+ if (_M_stack.empty())
+ __throw_regex_error(regex_constants::error_badrepeat);
+ _StateSeq __r(_M_stack.top(), -1);
+ __r._M_append(__r._M_front());
+ _M_stack.pop();
+ _M_stack.push(__r);
+ return true;
+ }
+ if (_M_match_token(_ScannerT::_S_token_closure1))
+ {
+ if (_M_stack.empty())
+ __throw_regex_error(regex_constants::error_badrepeat);
+ _StateSeq __r(_M_state_store,
+ _M_state_store._M_insert_alt(_S_invalid_state_id,
+ _M_stack.top()._M_front()));
+ _M_stack.top()._M_append(__r);
+ return true;
+ }
+ if (_M_match_token(_ScannerT::_S_token_opt))
+ {
+ if (_M_stack.empty())
+ __throw_regex_error(regex_constants::error_badrepeat);
+ _StateSeq __r(_M_stack.top(), -1);
+ _M_stack.pop();
+ _M_stack.push(__r);
+ return true;
+ }
+ if (_M_match_token(_ScannerT::_S_token_interval_begin))
+ {
+ if (_M_stack.empty())
+ __throw_regex_error(regex_constants::error_badrepeat);
+ if (!_M_match_token(_ScannerT::_S_token_dup_count))
+ __throw_regex_error(regex_constants::error_badbrace);
+ _StateSeq __r(_M_stack.top());
+ int __min_rep = _M_cur_int_value(10);
+ for (int __i = 1; __i < __min_rep; ++__i)
+ _M_stack.top()._M_append(__r._M_clone());
+ if (_M_match_token(_ScannerT::_S_token_comma))
+ if (_M_match_token(_ScannerT::_S_token_dup_count))
+ {
+ int __n = _M_cur_int_value(10) - __min_rep;
+ if (__n < 0)
+ __throw_regex_error(regex_constants::error_badbrace);
+ for (int __i = 0; __i < __n; ++__i)
+ {
+ _StateSeq __r(_M_state_store,
+ _M_state_store._M_insert_alt(_S_invalid_state_id,
+ _M_stack.top()._M_front()));
+ _M_stack.top()._M_append(__r);
+ }
+ }
+ else
+ {
+ _StateSeq __r(_M_stack.top(), -1);
+ __r._M_push_back(__r._M_front());
+ _M_stack.pop();
+ _M_stack.push(__r);
+ }
+ if (!_M_match_token(_ScannerT::_S_token_interval_end))
+ __throw_regex_error(regex_constants::error_brace);
+ return true;
+ }
+ return false;
+ }
+
+ template<typename _InIter, typename _TraitsT>
+ bool
+ _Compiler<_InIter, _TraitsT>::
+ _M_atom()
+ {
+ using std::bind;
+ using std::placeholders::_1;
+ using std::placeholders::_2;
+ typedef _CharMatcher<_InIter, _TraitsT> _CMatcher;
+ typedef _StartTagger<_InIter, _TraitsT> _Start;
+ typedef _EndTagger<_InIter, _TraitsT> _End;
+
+ if (_M_match_token(_ScannerT::_S_token_anychar))
+ {
+ _M_stack.push(_StateSeq(_M_state_store,
+ _M_state_store._M_insert_matcher(bind(_AnyMatcher, _1))));
+ return true;
+ }
+ if (_M_match_token(_ScannerT::_S_token_ord_char))
+ {
+ _M_stack.push(_StateSeq(_M_state_store,
+ _M_state_store._M_insert_matcher(
+ bind(_CMatcher(_M_cur_value[0], _M_traits), _1))));
+ return true;
+ }
+ if (_M_match_token(_ScannerT::_S_token_quoted_char))
+ {
+ // note that in the ECMA grammar, this case covers backrefs.
+ _M_stack.push(_StateSeq(_M_state_store,
+ _M_state_store._M_insert_matcher(
+ bind(_CMatcher(_M_cur_value[0], _M_traits), _1))));
+ return true;
+ }
+ if (_M_match_token(_ScannerT::_S_token_backref))
+ {
+ // __m.push(_Matcher::_S_opcode_ordchar, _M_cur_value);
+ return true;
+ }
+ if (_M_match_token(_ScannerT::_S_token_subexpr_begin))
+ {
+ int __mark = _M_state_store._M_sub_count();
+ _StateSeq __r(_M_state_store,
+ _M_state_store._M_insert_subexpr_begin(bind(_Start(__mark), _1, _2)));
+ this->_M_disjunction();
+ if (!_M_match_token(_ScannerT::_S_token_subexpr_end))
+ __throw_regex_error(regex_constants::error_paren);
+ if (!_M_stack.empty())
+ {
+ __r._M_append(_M_stack.top());
+ _M_stack.pop();
+ }
+ __r._M_append(_M_state_store._M_insert_subexpr_end(__mark,
+ bind(_End(__mark), _1, _2)));
+ _M_stack.push(__r);
+ return true;
+ }
+ return _M_bracket_expression();
+ }
+
+ template<typename _InIter, typename _TraitsT>
+ bool
+ _Compiler<_InIter, _TraitsT>::
+ _M_bracket_expression()
+ {
+ using std::bind;
+ using std::placeholders::_1;
+ if (_M_match_token(_ScannerT::_S_token_bracket_begin))
+ {
+ _RMatcherT __matcher(_M_match_token(_ScannerT::_S_token_line_begin),
+ _M_traits);
+ if (!_M_bracket_list(__matcher)
+ || !_M_match_token(_ScannerT::_S_token_bracket_end))
+ __throw_regex_error(regex_constants::error_brack);
+ _M_stack.push(_StateSeq(_M_state_store,
+ _M_state_store._M_insert_matcher(
+ bind(__matcher, _1))));
+ return true;
+ }
+ return false;
+ }
+
+ // If the dash is the last character in the bracket expression, it is not
+ // special.
+ template<typename _InIter, typename _TraitsT>
+ bool
+ _Compiler<_InIter, _TraitsT>::
+ _M_bracket_list(_RMatcherT& __matcher)
+ {
+ if (_M_follow_list(__matcher))
+ {
+ if (_M_match_token(_ScannerT::_S_token_dash))
+ __matcher._M_add_char(_M_cur_value[0]);
+ return true;
+ }
+ return false;
+ }
+
+ template<typename _InIter, typename _TraitsT>
+ bool
+ _Compiler<_InIter, _TraitsT>::
+ _M_follow_list(_RMatcherT& __matcher)
+ { return _M_expression_term(__matcher) && _M_follow_list2(__matcher); }
+
+ template<typename _InIter, typename _TraitsT>
+ bool
+ _Compiler<_InIter, _TraitsT>::
+ _M_follow_list2(_RMatcherT& __matcher)
+ {
+ if (_M_expression_term(__matcher))
+ return _M_follow_list2(__matcher);
+ return true;
+ }
+
+ template<typename _InIter, typename _TraitsT>
+ bool
+ _Compiler<_InIter, _TraitsT>::
+ _M_expression_term(_RMatcherT& __matcher)
+ {
+ return _M_collating_symbol(__matcher)
+ || _M_character_class(__matcher)
+ || _M_equivalence_class(__matcher)
+ || (_M_start_range(__matcher) && _M_range_expression(__matcher));
+ }
+
+ template<typename _InIter, typename _TraitsT>
+ bool
+ _Compiler<_InIter, _TraitsT>::
+ _M_range_expression(_RMatcherT& __matcher)
+ {
+ if (!_M_collating_symbol(__matcher))
+ if (!_M_match_token(_ScannerT::_S_token_dash))
+ __throw_regex_error(regex_constants::error_range);
+ __matcher._M_make_range();
+ return true;
+ }
+
+ template<typename _InIter, typename _TraitsT>
+ bool
+ _Compiler<_InIter, _TraitsT>::
+ _M_start_range(_RMatcherT& __matcher)
+ { return _M_match_token(_ScannerT::_S_token_dash); }
+
+ template<typename _InIter, typename _TraitsT>
+ bool
+ _Compiler<_InIter, _TraitsT>::
+ _M_collating_symbol(_RMatcherT& __matcher)
+ {
+ if (_M_match_token(_ScannerT::_S_token_collelem_single))
+ {
+ __matcher._M_add_char(_M_cur_value[0]);
+ return true;
+ }
+ if (_M_match_token(_ScannerT::_S_token_collsymbol))
+ {
+ __matcher._M_add_collating_element(_M_cur_value);
+ return true;
+ }
+ return false;
+ }
+
+ template<typename _InIter, typename _TraitsT>
+ bool
+ _Compiler<_InIter, _TraitsT>::
+ _M_equivalence_class(_RMatcherT& __matcher)
+ {
+ if (_M_match_token(_ScannerT::_S_token_equiv_class_name))
+ {
+ __matcher._M_add_equivalence_class(_M_cur_value);
+ return true;
+ }
+ return false;
+ }
+
+ template<typename _InIter, typename _TraitsT>
+ bool
+ _Compiler<_InIter, _TraitsT>::
+ _M_character_class(_RMatcherT& __matcher)
+ {
+ if (_M_match_token(_ScannerT::_S_token_char_class_name))
+ {
+ __matcher._M_add_character_class(_M_cur_value);
+ return true;
+ }
+ return false;
+ }
+
+ template<typename _InIter, typename _TraitsT>
+ int
+ _Compiler<_InIter, _TraitsT>::
+ _M_cur_int_value(int __radix)
+ {
+ int __v = 0;
+ for (typename _StringT::size_type __i = 0;
+ __i < _M_cur_value.length(); ++__i)
+ __v =__v * __radix + _M_traits.value(_M_cur_value[__i], __radix);
+ return __v;
+ }
+
+ template<typename _InIter, typename _TraitsT>
+ _AutomatonPtr
+ __compile(const _InIter& __b, const _InIter& __e, _TraitsT& __t,
+ regex_constants::syntax_option_type __f)
+ { return _AutomatonPtr(new _Nfa(_Compiler<_InIter, _TraitsT>(__b, __e, __t,
+ __f)._M_nfa())); }
+
+} // namespace __regex
+} // namespace std
+
+/* vim: set ts=8 sw=2 sts=2: */
diff --git a/libstdc++-v3/include/bits/regex_constants.h b/libstdc++-v3/include/bits/regex_constants.h
new file mode 100644
index 00000000000..787b88b8cd4
--- /dev/null
+++ b/libstdc++-v3/include/bits/regex_constants.h
@@ -0,0 +1,299 @@
+// class template regex -*- C++ -*-
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+/**
+ * @file bits/regex_constants
+ * @brief Constant definitions for the std regex library.
+ *
+ * This is an internal header file, included by other library headers.
+ * You should not attempt to use it directly.
+ */
+
+namespace std
+{
+
+/**
+ * @namespace std::regex_constants
+ * @brief ISO C++-0x entities sub namespace for regex.
+ */
+namespace regex_constants
+{
+ /**
+ * @name 5.1 Regular Expression Syntax Options
+ */
+ //@{
+ enum __syntax_option
+ {
+ _S_icase,
+ _S_nosubs,
+ _S_optimize,
+ _S_collate,
+ _S_ECMAScript,
+ _S_basic,
+ _S_extended,
+ _S_awk,
+ _S_grep,
+ _S_egrep,
+ _S_syntax_last
+ };
+
+ /**
+ * @brief This is a bitmask type indicating how to interpret the regex.
+ *
+ * The @c syntax_option_type is implementation defined but it is valid to
+ * perform bitwise operations on these values and expect the right thing to
+ * happen.
+ *
+ * A valid value of type syntax_option_type shall have exactly one of the
+ * elements @c ECMAScript, @c basic, @c extended, @c awk, @c grep, @c egrep
+ * %set.
+ */
+ typedef unsigned int syntax_option_type;
+
+ /**
+ * Specifies that the matching of regular expressions against a character
+ * sequence shall be performed without regard to case.
+ */
+ static const syntax_option_type icase = 1 << _S_icase;
+
+ /**
+ * Specifies that when a regular expression is matched against a character
+ * container sequence, no sub-expression matches are to be stored in the
+ * supplied match_results structure.
+ */
+ static const syntax_option_type nosubs = 1 << _S_nosubs;
+
+ /**
+ * Specifies that the regular expression engine should pay more attention to
+ * the speed with which regular expressions are matched, and less to the
+ * speed with which regular expression objects are constructed. Otherwise
+ * it has no detectable effect on the program output.
+ */
+ static const syntax_option_type optimize = 1 << _S_optimize;
+
+ /**
+ * Specifies that character ranges of the form [a-b] should be locale
+ * sensitive.
+ */
+ static const syntax_option_type collate = 1 << _S_collate;
+
+ /**
+ * Specifies that the grammar recognized by the regular expression engine is
+ * that used by ECMAScript in ECMA-262 [Ecma International, ECMAScript
+ * Language Specification, Standard Ecma-262, third edition, 1999], as
+ * modified in section [28.13]. This grammar is similar to that defined
+ * in the PERL scripting language but extended with elements found in the
+ * POSIX regular expression grammar.
+ */
+ static const syntax_option_type ECMAScript = 1 << _S_ECMAScript;
+
+ /**
+ * Specifies that the grammar recognized by the regular expression engine is
+ * that used by POSIX basic regular expressions in IEEE Std 1003.1-2001,
+ * Portable Operating System Interface (POSIX), Base Definitions and
+ * Headers, Section 9, Regular Expressions [IEEE, Information Technology --
+ * Portable Operating System Interface (POSIX), IEEE Standard 1003.1-2001].
+ */
+ static const syntax_option_type basic = 1 << _S_basic;
+
+ /**
+ * Specifies that the grammar recognized by the regular expression engine is
+ * that used by POSIX extended regular expressions in IEEE Std 1003.1-2001,
+ * Portable Operating System Interface (POSIX), Base Definitions and Headers,
+ * Section 9, Regular Expressions.
+ */
+ static const syntax_option_type extended = 1 << _S_extended;
+
+ /**
+ * Specifies that the grammar recognized by the regular expression engine is
+ * that used by POSIX utility awk in IEEE Std 1003.1-2001. This option is
+ * identical to syntax_option_type extended, except that C-style escape
+ * sequences are supported. These sequences are:
+ * \\\\, \\a, \\b, \\f, \\n, \\r, \\t , \\v, \\&apos;, &apos;,
+ * and \\ddd (where ddd is one, two, or three octal digits).
+ */
+ static const syntax_option_type awk = 1 << _S_awk;
+
+ /**
+ * Specifies that the grammar recognized by the regular expression engine is
+ * that used by POSIX utility grep in IEEE Std 1003.1-2001. This option is
+ * identical to syntax_option_type basic, except that newlines are treated
+ * as whitespace.
+ */
+ static const syntax_option_type grep = 1 << _S_grep;
+
+ /**
+ * Specifies that the grammar recognized by the regular expression engine is
+ * that used by POSIX utility grep when given the -E option in
+ * IEEE Std 1003.1-2001. This option is identical to syntax_option_type
+ * extended, except that newlines are treated as whitespace.
+ */
+ static const syntax_option_type egrep = 1 << _S_egrep;
+
+ //@}
+
+ /**
+ * @name 5.2 Matching Rules
+ *
+ * Matching a regular expression against a sequence of characters [first,
+ * last) proceeds according to the rules of the grammar specified for the
+ * regular expression object, modified according to the effects listed
+ * below for any bitmask elements set.
+ *
+ */
+ //@{
+
+ enum __match_flag
+ {
+ _S_not_bol,
+ _S_not_eol,
+ _S_not_bow,
+ _S_not_eow,
+ _S_any,
+ _S_not_null,
+ _S_continuous,
+ _S_prev_avail,
+ _S_sed,
+ _S_no_copy,
+ _S_first_only,
+ _S_match_flag_last
+ };
+
+ /**
+ * @brief This is a bitmask type indicating regex matching rules.
+ *
+ * The @c match_flag_type is implementation defined but it is valid to
+ * perform bitwise operations on these values and expect the right thing to
+ * happen.
+ */
+ typedef std::bitset<_S_match_flag_last> match_flag_type;
+
+ /**
+ * The default matching rules.
+ */
+ static const match_flag_type match_default = 0;
+
+ /**
+ * The first character in the sequence [first, last) is treated as though it
+ * is not at the beginning of a line, so the character (^) in the regular
+ * expression shall not match [first, first).
+ */
+ static const match_flag_type match_not_bol = 1 << _S_not_bol;
+
+ /**
+ * The last character in the sequence [first, last) is treated as though it
+ * is not at the end of a line, so the character ($) in the regular
+ * expression shall not match [last, last).
+ */
+ static const match_flag_type match_not_eol = 1 << _S_not_eol;
+
+ /**
+ * The expression \\b is not matched against the sub-sequence
+ * [first,first).
+ */
+ static const match_flag_type match_not_bow = 1 << _S_not_bow;
+
+ /**
+ * The expression \\b should not be matched against the sub-sequence
+ * [last,last).
+ */
+ static const match_flag_type match_not_eow = 1 << _S_not_eow;
+
+ /**
+ * If more than one match is possible then any match is an acceptable
+ * result.
+ */
+ static const match_flag_type match_any = 1 << _S_any;
+
+ /**
+ * The expression does not match an empty sequence.
+ */
+ static const match_flag_type match_not_null = 1 << _S_not_null;
+
+ /**
+ * The expression only matches a sub-sequence that begins at first .
+ */
+ static const match_flag_type match_continuous = 1 << _S_continuous;
+
+ /**
+ * --first is a valid iterator position. When this flag is set then the
+ * flags match_not_bol and match_not_bow are ignored by the regular
+ * expression algorithms 7.11 and iterators 7.12.
+ */
+ static const match_flag_type match_prev_avail = 1 << _S_prev_avail;
+
+ /**
+ * When a regular expression match is to be replaced by a new string, the
+ * new string is constructed using the rules used by the ECMAScript replace
+ * function in ECMA- 262 [Ecma International, ECMAScript Language
+ * Specification, Standard Ecma-262, third edition, 1999], part 15.5.4.11
+ * String.prototype.replace. In addition, during search and replace
+ * operations all non-overlapping occurrences of the regular expression
+ * are located and replaced, and sections of the input that did not match
+ * the expression are copied unchanged to the output string.
+ *
+ * Format strings (from ECMA-262 [15.5.4.11]):
+ * @li $$ The dollar-sign itself ($)
+ * @li $& The matched substring.
+ * @li $` The portion of @a string that precedes the matched substring.
+ * This would be match_results::prefix().
+ * @li $' The portion of @a string that follows the matched substring.
+ * This would be match_results::suffix().
+ * @li $n The nth capture, where n is in [1,9] and $n is not followed by a
+ * decimal digit. If n <= match_results::size() and the nth capture
+ * is undefined, use the empty string instead. If n >
+ * match_results::size(), the result is implementation-defined.
+ * @li $nn The nnth capture, where nn is a two-digit decimal number on
+ * [01, 99]. If nn <= match_results::size() and the nth capture is
+ * undefined, use the empty string instead. If
+ * nn > match_results::size(), the result is implementation-defined.
+ */
+ static const match_flag_type format_default = 0;
+
+ /**
+ * When a regular expression match is to be replaced by a new string, the
+ * new string is constructed using the rules used by the POSIX sed utility
+ * in IEEE Std 1003.1- 2001 [IEEE, Information Technology -- Portable
+ * Operating System Interface (POSIX), IEEE Standard 1003.1-2001].
+ */
+ static const match_flag_type format_sed = 1 << _S_sed;
+
+ /**
+ * During a search and replace operation, sections of the character
+ * container sequence being searched that do not match the regular
+ * expression shall not be copied to the output string.
+ */
+ static const match_flag_type format_no_copy = 1 << _S_no_copy;
+
+ /**
+ * When specified during a search and replace operation, only the first
+ * occurrence of the regular expression shall be replaced.
+ */
+ static const match_flag_type format_first_only = 1 << _S_first_only;
+
+ //@}
+
+} // namespace regex_constants
+} // namespace std
+
diff --git a/libstdc++-v3/include/bits/regex_cursor.h b/libstdc++-v3/include/bits/regex_cursor.h
new file mode 100644
index 00000000000..0a293fae953
--- /dev/null
+++ b/libstdc++-v3/include/bits/regex_cursor.h
@@ -0,0 +1,92 @@
+// class template regex -*- C++ -*-
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+/**
+ * @file bits/regex_cursor.h
+ * This is an internal header file, included by other library headers.
+ * You should not attempt to use it directly.
+ */
+
+namespace std
+{
+namespace __regex
+{
+ // ABC for pattern matching
+ struct _PatternCursor
+ {
+ virtual ~_PatternCursor() { };
+ virtual void _M_next() = 0;
+ virtual bool _M_at_end() const = 0;
+ };
+
+ // Provides a cursor into the specific target string.
+ template<typename _FwdIterT>
+ class _SpecializedCursor
+ : public _PatternCursor
+ {
+ public:
+ _SpecializedCursor(const _FwdIterT& __b, const _FwdIterT __e)
+ : _M_b(__b), _M_c(__b), _M_e(__e)
+ { }
+
+ typename std::iterator_traits<_FwdIterT>::value_type
+ _M_current() const
+ { return *_M_c; }
+
+ void
+ _M_next()
+ { ++_M_c; }
+
+ _FwdIterT
+ _M_pos() const
+ { return _M_c; }
+
+ const _FwdIterT&
+ _M_begin() const
+ { return _M_b; }
+
+ const _FwdIterT&
+ _M_end() const
+ { return _M_e; }
+
+ bool
+ _M_at_end() const
+ { return _M_c == _M_e; }
+
+ private:
+ _FwdIterT _M_b;
+ _FwdIterT _M_c;
+ _FwdIterT _M_e;
+ };
+
+ // Helper funxtion to create a cursor specialized for an iterator class.
+ template<typename _FwdIterT>
+ _SpecializedCursor<_FwdIterT>
+ __cursor(const _FwdIterT& __b, const _FwdIterT __e)
+ { return _SpecializedCursor<_FwdIterT>(__b, __e); }
+
+} // namespace __regex
+} // namespace std
+
+/* vim: set ts=8 sw=2 sts=2: */
diff --git a/libstdc++-v3/include/bits/regex_error.h b/libstdc++-v3/include/bits/regex_error.h
new file mode 100644
index 00000000000..56bfae4cc66
--- /dev/null
+++ b/libstdc++-v3/include/bits/regex_error.h
@@ -0,0 +1,160 @@
+// class template regex -*- C++ -*-
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+/**
+ * @file bits/regex_error
+ * @brief Error and exception objects for the std regex library.
+ *
+ * This is an internal header file, included by other library headers.
+ * You should not attempt to use it directly.
+ */
+
+namespace std
+{
+
+namespace regex_constants
+{
+ /**
+ * @name 5.3 Error Types
+ */
+ //@{
+
+ enum error_type
+ {
+ _S_error_collate,
+ _S_error_ctype,
+ _S_error_escape,
+ _S_error_backref,
+ _S_error_brack,
+ _S_error_paren,
+ _S_error_brace,
+ _S_error_badbrace,
+ _S_error_range,
+ _S_error_space,
+ _S_error_badrepeat,
+ _S_error_complexity,
+ _S_error_stack,
+ _S_error_last
+ };
+
+ /** The expression contained an invalid collating element name. */
+ static const error_type error_collate(_S_error_collate);
+
+ /** The expression contained an invalid character class name. */
+ static const error_type error_ctype(_S_error_ctype);
+
+ /**
+ * The expression contained an invalid escaped character, or a trailing
+ * escape.
+ */
+ static const error_type error_escape(_S_error_escape);
+
+ /** The expression contained an invalid back reference. */
+ static const error_type error_backref(_S_error_backref);
+
+ /** The expression contained mismatched [ and ]. */
+ static const error_type error_brack(_S_error_brack);
+
+ /** The expression contained mismatched ( and ). */
+ static const error_type error_paren(_S_error_paren);
+
+ /** The expression contained mismatched { and } */
+ static const error_type error_brace(_S_error_brace);
+
+ /** The expression contained an invalid range in a {} expression. */
+ static const error_type error_badbrace(_S_error_badbrace);
+
+ /**
+ * The expression contained an invalid character range,
+ * such as [b-a] in most encodings.
+ */
+ static const error_type error_range(_S_error_range);
+
+ /**
+ * There was insufficient memory to convert the expression into a
+ * finite state machine.
+ */
+ static const error_type error_space(_S_error_space);
+
+ /**
+ * One of <em>*?+{<em> was not preceded by a valid regular expression.
+ */
+ static const error_type error_badrepeat(_S_error_badrepeat);
+
+ /**
+ * The complexity of an attempted match against a regular expression
+ * exceeded a pre-set level.
+ */
+ static const error_type error_complexity(_S_error_complexity);
+
+ /**
+ * There was insufficient memory to determine whether the
+ * regular expression could match the specified character sequence.
+ */
+ static const error_type error_stack(_S_error_stack);
+
+ //@}
+}
+
+ // [7.8] Class regex_error
+ /**
+ * @brief A regular expression exception class.
+ * @ingroup exceptions
+ *
+ * The regular expression library throws objects of this class on error.
+ */
+ class regex_error
+ : public std::runtime_error
+ {
+ public:
+ /**
+ * @brief Constructs a regex_error object.
+ *
+ * @param ecode the regex error code.
+ */
+ explicit
+ regex_error(regex_constants::error_type __ecode)
+ : std::runtime_error("regex_error"), _M_code(__ecode)
+ { }
+
+ /**
+ * @brief Gets the regex error code.
+ *
+ * @returns the regex error code.
+ */
+ regex_constants::error_type
+ code() const
+ { return _M_code; }
+
+ protected:
+ regex_constants::error_type _M_code;
+ };
+
+
+ inline void
+ __throw_regex_error(regex_constants::error_type __ecode)
+ { throw regex_error(__ecode); }
+
+} // namespace std
+
diff --git a/libstdc++-v3/include/bits/regex_grep_matcher.h b/libstdc++-v3/include/bits/regex_grep_matcher.h
new file mode 100644
index 00000000000..f243c92406b
--- /dev/null
+++ b/libstdc++-v3/include/bits/regex_grep_matcher.h
@@ -0,0 +1,131 @@
+// class template regex -*- C++ -*-
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+/**
+ * @file bits/regex_executor.h
+ * This is an internal header file, included by other library headers.
+ * You should not attempt to use it directly.
+ */
+
+
+namespace std
+{
+ template<typename _BiIter>
+ class sub_match;
+
+ template<typename _Bi_iter, typename _Allocator>
+ class match_results;
+
+namespace __regex
+{
+ // A _Results facade specialized for wrapping a templated sub_match.
+ template<typename _FwdIterT, typename _Alloc>
+ class _SpecializedResults
+ : public _Results
+ {
+ public:
+ _SpecializedResults(const _Automaton::_SizeT __size,
+ const _SpecializedCursor<_FwdIterT>& __cursor,
+ match_results<_FwdIterT, _Alloc>& __m);
+
+ void
+ _M_set_pos(int __i, int __j, const _PatternCursor& __pc);
+
+ void
+ _M_set_matched(int __i, bool __is_matched)
+ { _M_results.at(__i).matched = __is_matched; }
+
+ private:
+ match_results<_FwdIterT, _Alloc>& _M_results;
+ };
+
+ template<typename _FwdIterT, typename _Alloc>
+ _SpecializedResults<_FwdIterT, _Alloc>::
+ _SpecializedResults(const _Automaton::_SizeT __size,
+ const _SpecializedCursor<_FwdIterT>& __cursor,
+ match_results<_FwdIterT, _Alloc>& __m)
+ : _M_results(__m)
+ {
+ typedef typename match_results<_FwdIterT, _Alloc>::size_type size_type;
+ _M_results.clear();
+ std::sub_match<_FwdIterT> __sm;
+ __sm.matched = false;
+ size_type __result_count = __size + 2;
+ for (size_type __i = 0; __i < __result_count; ++__i)
+ _M_results.push_back(__sm);
+ _M_results.at(__size+0).first = __cursor._M_begin();
+ _M_results.at(__size+0).second = __cursor._M_begin();
+ _M_results.at(__size+1).first = __cursor._M_end();
+ _M_results.at(__size+1).second = __cursor._M_end();
+ }
+
+ template<typename _FwdIterT, typename _Alloc>
+ void
+ _SpecializedResults<_FwdIterT, _Alloc>::
+ _M_set_pos(int __i, int __j, const _PatternCursor& __pc)
+ {
+ typedef const _SpecializedCursor<_FwdIterT>& _CursorT;
+ _CursorT __c = static_cast<_CursorT>(__pc);
+ if (__j == 0)
+ _M_results.at(__i).first = __c._M_pos();
+ else
+ _M_results.at(__i).second = __c._M_pos()+1;
+ }
+
+ // A stack of states used in evaluating the NFA.
+ typedef std::stack<_StateIdT, std::vector<_StateIdT> > _StateStack;
+
+ // Executes a regular expression NFA/DFA over a range using a variant of
+ // the parallel execution algorithm featured in the grep utility, modified
+ // to use Laurikari tags.
+ class _Grep_matcher
+ {
+ public:
+ _Grep_matcher(_PatternCursor& __p,
+ _Results& __r,
+ const _AutomatonPtr& __automaton,
+ regex_constants::match_flag_type __flags);
+
+ private:
+ _StateSet
+ _M_e_closure(_StateIdT __i);
+
+ _StateSet
+ _M_e_closure(const _StateSet& __s);
+
+ _StateSet
+ _M_e_closure(_StateStack& __stack, const _StateSet& __s);
+
+ private:
+ const std::shared_ptr<_Nfa> _M_nfa;
+ _PatternCursor& _M_pattern;
+ _Results& _M_results;
+ };
+
+} // namespace __regex
+} // namespace std
+
+#include <bits/regex_grep_matcher.tcc>
+
+/* vim: set ts=8 sw=2 sts=2: */
diff --git a/libstdc++-v3/include/bits/regex_grep_matcher.tcc b/libstdc++-v3/include/bits/regex_grep_matcher.tcc
new file mode 100644
index 00000000000..e43975765b8
--- /dev/null
+++ b/libstdc++-v3/include/bits/regex_grep_matcher.tcc
@@ -0,0 +1,179 @@
+// class template regex -*- C++ -*-
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+/**
+ * @file regex_grep_matcher.cc
+ */
+#include <regex>
+
+namespace std
+{
+
+namespace
+{
+
+ // A stack of states used in evaluating the NFA.
+ typedef std::stack<
+ std::__regex::_StateIdT,
+ std::vector<std::__regex::_StateIdT>
+ > _StateStack;
+
+ // Obtains the next state set given the current state set __s and the current
+ // input character.
+ inline std::__regex::_StateSet
+ __move(const std::__regex::_PatternCursor& __p,
+ const std::__regex::_Nfa& __nfa,
+ const std::__regex::_StateSet& __s)
+ {
+ std::__regex::_StateSet __m;
+ for (std::__regex::_StateSet::const_iterator __i = __s.begin();
+ __i != __s.end(); ++__i)
+ {
+ if (*__i == std::__regex::_S_invalid_state_id)
+ continue;
+
+ const std::__regex::_State& __state = __nfa[*__i];
+ if (__state._M_opcode == std::__regex::_S_opcode_match
+ && __state._M_matches(__p))
+ __m.insert(__state._M_next);
+ }
+ return __m;
+ }
+
+ // returns true if (__s intersect __t) is not empty
+ inline bool
+ __includes_some(const std::__regex::_StateSet& __s,
+ const std::__regex::_StateSet& __t)
+ {
+ if (__s.size() > 0 && __t.size() > 0)
+ {
+ std::__regex::_StateSet::const_iterator __first = __s.begin();
+ std::__regex::_StateSet::const_iterator __second = __t.begin();
+ while (__first != __s.end() && __second != __t.end())
+ {
+ if (*__first < *__second)
+ ++__first;
+ else if (*__second < *__first)
+ ++__second;
+ else
+ return true;
+ }
+ }
+ return false;
+ }
+
+ // If an identified state __u is not already in the current state set __e,
+ // insert it and push it on the current state stack __s.
+ inline void
+ __add_visited_state(const std::__regex::_StateIdT __u,
+ _StateStack& __s,
+ std::__regex::_StateSet& __e)
+ {
+ if (__e.count(__u) == 0)
+ {
+ __e.insert(__u);
+ __s.push(__u);
+ }
+ }
+
+} // anonymous namespace
+
+namespace __regex
+{
+ inline _Grep_matcher::
+ _Grep_matcher(_PatternCursor& __p,
+ _Results& __r,
+ const _AutomatonPtr& __nfa,
+ regex_constants::match_flag_type __flags)
+ : _M_nfa(static_pointer_cast<_Nfa>(__nfa)), _M_pattern(__p), _M_results(__r)
+ {
+ __regex::_StateSet __t = this->_M_e_closure(_M_nfa->_M_start());
+ for (; !_M_pattern._M_at_end(); _M_pattern._M_next())
+ __t = this->_M_e_closure(__move(_M_pattern, *_M_nfa, __t));
+
+ _M_results._M_set_matched(0,
+ __includes_some(_M_nfa->_M_final_states(), __t));
+ }
+
+ // Creates the e-closure set for the initial state __i.
+ inline _StateSet _Grep_matcher::
+ _M_e_closure(_StateIdT __i)
+ {
+ _StateSet __s;
+ __s.insert(__i);
+ _StateStack __stack;
+ __stack.push(__i);
+ return this->_M_e_closure(__stack, __s);
+ }
+
+ // Creates the e-closure set for an arbitrary state set __s.
+ inline _StateSet _Grep_matcher::
+ _M_e_closure(const _StateSet& __s)
+ {
+ _StateStack __stack;
+ for (_StateSet::const_iterator __i = __s.begin(); __i != __s.end(); ++__i)
+ __stack.push(*__i);
+ return this->_M_e_closure(__stack, __s);
+ }
+
+ inline _StateSet _Grep_matcher::
+ _M_e_closure(_StateStack& __stack, const _StateSet& __s)
+ {
+ _StateSet __e = __s;
+ while (!__stack.empty())
+ {
+ _StateIdT __t = __stack.top(); __stack.pop();
+ if (__t == _S_invalid_state_id)
+ continue;
+ // for each __u with edge from __t to __u labeled e do ...
+ const _State& __state = _M_nfa->operator[](__t);
+ switch (__state._M_opcode)
+ {
+ case _S_opcode_alternative:
+ __add_visited_state(__state._M_next, __stack, __e);
+ __add_visited_state(__state._M_alt, __stack, __e);
+ break;
+ case _S_opcode_subexpr_begin:
+ __add_visited_state(__state._M_next, __stack, __e);
+ __state._M_tagger(_M_pattern, _M_results);
+ break;
+ case _S_opcode_subexpr_end:
+ __add_visited_state(__state._M_next, __stack, __e);
+ __state._M_tagger(_M_pattern, _M_results);
+ _M_results._M_set_matched(__state._M_subexpr, true);
+ break;
+ case _S_opcode_accept:
+ __add_visited_state(__state._M_next, __stack, __e);
+ break;
+ default:
+ break;
+ }
+ }
+ return __e;
+ }
+
+} // namespace __regex
+} // namespace std
+
+/* vim: set ts=8 sw=2 sts=2: */
diff --git a/libstdc++-v3/include/bits/regex_nfa.h b/libstdc++-v3/include/bits/regex_nfa.h
new file mode 100644
index 00000000000..2a938915b97
--- /dev/null
+++ b/libstdc++-v3/include/bits/regex_nfa.h
@@ -0,0 +1,403 @@
+// class template regex -*- C++ -*-
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+/**
+ * @file bits/regex_nfa.h
+ * This is an internal header file, included by other library headers.
+ * You should not attempt to use it directly.
+ */
+
+namespace std
+{
+namespace __regex
+{
+
+ // Base class for, um, automata. Could be an NFA or a DFA. Your choice.
+ class _Automaton
+ {
+ public:
+ typedef unsigned int _SizeT;
+
+ public:
+ virtual
+ ~_Automaton()
+ { }
+
+ virtual _SizeT
+ _M_sub_count() const = 0;
+
+#ifdef _GLIBCXX_DEBUG
+ virtual std::ostream&
+ _M_dot(std::ostream& __ostr) const = 0;
+#endif
+ };
+
+ // Generic shred pointer to an automaton.
+ typedef std::shared_ptr<_Automaton> _AutomatonPtr;
+
+ // Operation codes that define the type of transitions within the base NFA
+ // that represents the regular expression.
+ enum _Opcode
+ {
+ _S_opcode_unknown = 0,
+ _S_opcode_alternative = 1,
+ _S_opcode_subexpr_begin = 4,
+ _S_opcode_subexpr_end = 5,
+ _S_opcode_match = 100,
+ _S_opcode_accept = 255
+ };
+
+ // Provides a generic facade for a templated match_results.
+ struct _Results
+ {
+ virtual void _M_set_pos(int __i, int __j, const _PatternCursor& __p) = 0;
+ virtual void _M_set_matched(int __i, bool __is_matched) = 0;
+ };
+
+ // Tags current state (for subexpr begin/end).
+ typedef std::function<void (const _PatternCursor&, _Results&)> _Tagger;
+
+ template<typename _FwdIterT, typename _TraitsT>
+ struct _StartTagger
+ : public _Tagger
+ {
+ explicit
+ _StartTagger(int __i)
+ : _M_index(__i)
+ { }
+
+ void
+ operator()(const _PatternCursor& __pc, _Results& __r)
+ { __r._M_set_pos(_M_index, 0, __pc); }
+
+ int _M_index;
+ };
+
+ template<typename _FwdIterT, typename _TraitsT>
+ struct _EndTagger
+ : public _Tagger
+ {
+ explicit
+ _EndTagger(int __i)
+ : _M_index(__i)
+ { }
+
+ void
+ operator()(const _PatternCursor& __pc, _Results& __r)
+ { __r._M_set_pos(_M_index, 1, __pc); }
+
+ int _M_index;
+ _FwdIterT _M_pos;
+ };
+ // Indicates if current state matches cursor current.
+ typedef std::function<bool (const _PatternCursor&)> _Matcher;
+
+ // Matches any character
+ inline bool
+ _AnyMatcher(const _PatternCursor&)
+ { return true; }
+
+ // Matches a single character
+ template<typename _InIterT, typename _TraitsT>
+ struct _CharMatcher
+ : public _Matcher
+ {
+ typedef typename _TraitsT::char_type char_type;
+
+ explicit
+ _CharMatcher(char_type __c, const _TraitsT& __t = _TraitsT())
+ : _M_traits(__t), _M_c(_M_traits.translate(__c))
+ { }
+
+ bool
+ operator()(const _PatternCursor& __pc) const
+ {
+ typedef const _SpecializedCursor<_InIterT>& _CursorT;
+ _CursorT __c = static_cast<_CursorT>(__pc);
+ return _M_traits.translate(__c._M_current()) == _M_c;
+ }
+
+ const _TraitsT& _M_traits;
+ char_type _M_c;
+ };
+
+ // Matches a character range (bracket expression)
+ template<typename _InIterT, typename _TraitsT>
+ struct _RangeMatcher
+ : public _Matcher
+ {
+ typedef typename _TraitsT::char_type _CharT;
+ typedef std::basic_string<_CharT> _StringT;
+
+ explicit
+ _RangeMatcher(bool __is_non_matching, const _TraitsT& __t = _TraitsT())
+ : _M_traits(__t), _M_is_non_matching(__is_non_matching)
+ { }
+
+ bool
+ operator()(const _PatternCursor& __pc) const
+ {
+ typedef const _SpecializedCursor<_InIterT>& _CursorT;
+ _CursorT __c = static_cast<_CursorT>(__pc);
+ return true;
+ }
+
+ void
+ _M_add_char(_CharT __c)
+ { }
+
+ void
+ _M_add_collating_element(const _StringT& __s)
+ { }
+
+ void
+ _M_add_equivalence_class(const _StringT& __s)
+ { }
+
+ void
+ _M_add_character_class(const _StringT& __s)
+ { }
+
+ void
+ _M_make_range()
+ { }
+
+ const _TraitsT& _M_traits;
+ bool _M_is_non_matching;
+ };
+
+ // Identifies a state in the NFA.
+ typedef int _StateIdT;
+
+ // The special case in which a state identifier is not an index.
+ static const _StateIdT _S_invalid_state_id = -1;
+
+
+ // An individual state in an NFA
+ //
+ // In this case a "state" is an entry in the NFA definition coupled with its
+ // outgoing transition(s). All states have a single outgoing transition,
+ // except for accepting states (which have no outgoing transitions) and alt
+ // states, which have two outgoing transitions.
+ //
+ struct _State
+ {
+ typedef int _OpcodeT;
+
+ _OpcodeT _M_opcode; // type of outgoing transition
+ _StateIdT _M_next; // outgoing tranition
+ _StateIdT _M_alt; // for _S_opcode_alternative
+ unsigned int _M_subexpr; // for _S_opcode_subexpr_*
+ _Tagger _M_tagger; // for _S_opcode_subexpr_*
+ _Matcher _M_matches; // for _S_opcode_match
+
+ explicit _State(_OpcodeT __opcode)
+ : _M_opcode(__opcode), _M_next(_S_invalid_state_id)
+ { }
+
+ _State(const _Matcher& __m)
+ : _M_opcode(_S_opcode_match), _M_next(_S_invalid_state_id), _M_matches(__m)
+ { }
+
+ _State(_OpcodeT __opcode, unsigned int __s, const _Tagger& __t)
+ : _M_opcode(__opcode), _M_next(_S_invalid_state_id), _M_subexpr(__s),
+ _M_tagger(__t)
+ { }
+
+ _State(_StateIdT __next, _StateIdT __alt)
+ : _M_opcode(_S_opcode_alternative), _M_next(__next), _M_alt(__alt)
+ { }
+
+#ifdef _GLIBCXX_DEBUG
+ std::ostream&
+ _M_print(std::ostream& ostr) const;
+
+ // Prints graphviz dot commands for state.
+ std::ostream&
+ _M_dot(std::ostream& __ostr, _StateIdT __id) const;
+#endif
+ };
+
+
+ // The Grep Matcher works on sets of states. Here are sets of states.
+ typedef std::set<_StateIdT> _StateSet;
+
+ // A collection of all states making up an NFA
+ //
+ // An NFA is a 4-tuple M = (K, S, s, F), where
+ // K is a finite set of states,
+ // S is the alphabet of the NFA,
+ // s is the initial state,
+ // F is a set of final (accepting) states.
+ //
+ // This NFA class is templated on S, a type that will hold values of the
+ // underlying alphabet (without regard to semantics of that alphabet). The
+ // other elements of the tuple are generated during construction of the NFA
+ // and are available through accessor member functions.
+ //
+ class _Nfa
+ : public _Automaton, public std::vector<_State>
+ {
+ public:
+ typedef _State _StateT;
+ typedef unsigned int _SizeT;
+ typedef regex_constants::syntax_option_type _FlagT;
+
+ public:
+ _Nfa(_FlagT __f)
+ : _M_flags(__f), _M_start_state(0), _M_subexpr_count(0)
+ { }
+
+ ~_Nfa()
+ { }
+
+ _FlagT
+ _M_options() const
+ { return _M_flags; }
+
+ _StateIdT
+ _M_start() const
+ { return _M_start_state; }
+
+ const _StateSet&
+ _M_final_states() const
+ { return _M_accepting_states; }
+
+ _SizeT
+ _M_sub_count() const
+ { return _M_subexpr_count; }
+
+ _StateIdT
+ _M_insert_accept()
+ {
+ this->push_back(_StateT(_S_opcode_accept));
+ _M_accepting_states.insert(this->size()-1);
+ return this->size()-1;
+ }
+
+ _StateIdT
+ _M_insert_alt(_StateIdT __next, _StateIdT __alt)
+ {
+ this->push_back(_StateT(__next, __alt));
+ return this->size()-1;
+ }
+
+ _StateIdT
+ _M_insert_matcher(_Matcher __m)
+ {
+ this->push_back(_StateT(__m));
+ return this->size()-1;
+ }
+
+ _StateIdT
+ _M_insert_subexpr_begin(const _Tagger& __t)
+ {
+ this->push_back(_StateT(_S_opcode_subexpr_begin, _M_subexpr_count++, __t));
+ return this->size()-1;
+ }
+
+ _StateIdT
+ _M_insert_subexpr_end(unsigned int __i, const _Tagger& __t)
+ {
+ this->push_back(_StateT(_S_opcode_subexpr_end, __i, __t));
+ return this->size()-1;
+ }
+
+#ifdef _GLIBCXX_DEBUG
+ std::ostream&
+ _M_dot(std::ostream& __ostr) const;
+#endif
+
+ private:
+ _FlagT _M_flags;
+ _StateIdT _M_start_state;
+ _StateSet _M_accepting_states;
+ _SizeT _M_subexpr_count;
+ };
+
+ // Describes a sequence of one or more %_State, its current start and end(s).
+ //
+ // This structure contains fragments of an NFA during construction.
+ class _StateSeq
+ {
+ public:
+ // Constructs a single-node sequence
+ _StateSeq(_Nfa& __ss, _StateIdT __s, _StateIdT __e = _S_invalid_state_id)
+ : _M_nfa(__ss), _M_start(__s), _M_end1(__s), _M_end2(__e)
+ { }
+ // Constructs a split sequence from two other sequencces
+ _StateSeq(const _StateSeq& __e1, const _StateSeq& __e2)
+ : _M_nfa(__e1._M_nfa),
+ _M_start(_M_nfa._M_insert_alt(__e1._M_start, __e2._M_start)),
+ _M_end1(__e1._M_end1), _M_end2(__e2._M_end1)
+ { }
+
+ // Constructs a split sequence from a single sequence
+ _StateSeq(const _StateSeq& __e, _StateIdT __id)
+ : _M_nfa(__e._M_nfa),
+ _M_start(_M_nfa._M_insert_alt(__id, __e._M_start)),
+ _M_end1(__id), _M_end2(__e._M_end1)
+ { }
+
+ // Constructs a copy of a %_StateSeq
+ _StateSeq(const _StateSeq& __rhs)
+ : _M_nfa(__rhs._M_nfa), _M_start(__rhs._M_start),
+ _M_end1(__rhs._M_end1), _M_end2(__rhs._M_end2)
+ { }
+
+
+ _StateSeq& operator=(const _StateSeq& __rhs);
+
+ _StateIdT
+ _M_front() const
+ { return _M_start; }
+
+ // Extends a sequence by one.
+ void
+ _M_push_back(_StateIdT __id);
+
+ // Extends and maybe joins a sequence.
+ void
+ _M_append(_StateIdT __id);
+
+ void
+ _M_append(_StateSeq& __rhs);
+
+ // Clones an entire sequence.
+ _StateIdT
+ _M_clone();
+
+ private:
+ _Nfa& _M_nfa;
+ _StateIdT _M_start;
+ _StateIdT _M_end1;
+ _StateIdT _M_end2;
+
+ };
+
+} // namespace __regex
+} // namespace std
+
+#include <bits/regex_nfa.tcc>
+
diff --git a/libstdc++-v3/include/bits/regex_nfa.tcc b/libstdc++-v3/include/bits/regex_nfa.tcc
new file mode 100644
index 00000000000..38ab7e0b2ae
--- /dev/null
+++ b/libstdc++-v3/include/bits/regex_nfa.tcc
@@ -0,0 +1,170 @@
+// class template regex -*- C++ -*-
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+/**
+ * @file regex_nfa.cc
+ */
+#include <regex>
+
+namespace std
+{
+namespace __regex
+{
+#ifdef _GLIBCXX_DEBUG
+inline std::ostream& _State::
+_M_print(std::ostream& ostr) const
+{
+ switch (_M_opcode)
+ {
+ case _S_opcode_alternative:
+ ostr << "alt next=" << _M_next << " alt=" << _M_alt;
+ break;
+ case _S_opcode_subexpr_begin:
+ ostr << "subexpr begin next=" << _M_next << " index=" << _M_subexpr;
+ break;
+ case _S_opcode_subexpr_end:
+ ostr << "subexpr end next=" << _M_next << " index=" << _M_subexpr;
+ break;
+ case _S_opcode_match:
+ ostr << "match next=" << _M_next;
+ break;
+ case _S_opcode_accept:
+ ostr << "accept next=" << _M_next;
+ break;
+ default:
+ ostr << "unknown next=" << _M_next;
+ break;
+ }
+ return ostr;
+}
+
+// Prints graphviz dot commands for state.
+inline std::ostream& _State::
+_M_dot(std::ostream& __ostr, _StateIdT __id) const
+{
+ switch (_M_opcode)
+ {
+ case _S_opcode_alternative:
+ __ostr << __id << " [label=\"" << __id << "\\nALT\"];\n"
+ << __id << " -> " << _M_next
+ << " [label=\"epsilon\", tailport=\"s\"];\n"
+ << __id << " -> " << _M_alt
+ << " [label=\"epsilon\", tailport=\"n\"];\n";
+ break;
+ case _S_opcode_subexpr_begin:
+ __ostr << __id << " [label=\"" << __id << "\\nSBEGIN "
+ << _M_subexpr << "\"];\n"
+ << __id << " -> " << _M_next << " [label=\"epsilon\"];\n";
+ break;
+ case _S_opcode_subexpr_end:
+ __ostr << __id << " [label=\"" << __id << "\\nSEND "
+ << _M_subexpr << "\"];\n"
+ << __id << " -> " << _M_next << " [label=\"epsilon\"];\n";
+ break;
+ case _S_opcode_match:
+ __ostr << __id << " [label=\"" << __id << "\\nMATCH\"];\n"
+ << __id << " -> " << _M_next << " [label=\"<match>\"];\n";
+ break;
+ case _S_opcode_accept:
+ __ostr << __id << " [label=\"" << __id << "\\nACC\"];\n" ;
+ break;
+ default:
+ __ostr << __id << " [label=\"" << __id << "\\nUNK\"];\n"
+ << __id << " -> " << _M_next << " [label=\"?\"];\n";
+ break;
+ }
+ return __ostr;
+}
+
+inline std::ostream& _Nfa::
+_M_dot(std::ostream& __ostr) const
+{
+ __ostr << "digraph _Nfa {\n"
+ << " rankdir=LR;\n";
+ for (unsigned int __i = 0; __i < this->size(); ++__i)
+ { this->at(__i)._M_dot(__ostr, __i); }
+ __ostr << "}\n";
+ return __ostr;
+}
+#endif
+
+inline _StateSeq& _StateSeq::
+operator=(const _StateSeq& __rhs)
+{
+ _M_start = __rhs._M_start;
+ _M_end1 = __rhs._M_end1;
+ _M_end2 = __rhs._M_end2;
+ return *this;
+}
+
+inline void _StateSeq::
+_M_push_back(_StateIdT __id)
+{
+ if (_M_end1 != _S_invalid_state_id)
+ _M_nfa[_M_end1]._M_next = __id;
+ _M_end1 = __id;
+}
+
+inline void _StateSeq::
+_M_append(_StateIdT __id)
+{
+ if (_M_end2 != _S_invalid_state_id)
+ {
+ if (_M_end2 == _M_end1)
+ _M_nfa[_M_end2]._M_alt = __id;
+ else
+ _M_nfa[_M_end2]._M_next = __id;
+ _M_end2 = _S_invalid_state_id;
+ }
+ if (_M_end1 != _S_invalid_state_id)
+ _M_nfa[_M_end1]._M_next = __id;
+ _M_end1 = __id;
+}
+
+inline void _StateSeq::
+_M_append(_StateSeq& __rhs)
+{
+ if (_M_end2 != _S_invalid_state_id)
+ {
+ if (_M_end2 == _M_end1)
+ _M_nfa[_M_end2]._M_alt = __rhs._M_start;
+ else
+ _M_nfa[_M_end2]._M_next = __rhs._M_start;
+ _M_end2 = _S_invalid_state_id;
+ }
+ if (__rhs._M_end2 != _S_invalid_state_id)
+ _M_end2 = __rhs._M_end2;
+ if (_M_end1 != _S_invalid_state_id)
+ _M_nfa[_M_end1]._M_next = __rhs._M_start;
+ _M_end1 = __rhs._M_end1;
+}
+
+// @todo implement this function.
+inline _StateIdT _StateSeq::
+_M_clone()
+{ return 0; }
+
+} // namespace __regex
+} // namespace std
+
diff --git a/libstdc++-v3/include/std/regex b/libstdc++-v3/include/std/regex
index e8238299b22..95ad4239459 100644
--- a/libstdc++-v3/include/std/regex
+++ b/libstdc++-v3/include/std/regex
@@ -35,33 +35,30 @@
# include <bits/c++0x_warning.h>
#else
-#if defined(_GLIBCXX_INCLUDE_AS_TR1)
-# error C++0x header cannot be included from TR1 header
-#endif
-
#include <algorithm>
#include <bitset>
+#include <functional>
+#ifdef _GLIBCXX_DEBUG
+# include <iosfwd>
+#endif
#include <iterator>
#include <locale>
+#include <memory>
+#include <set>
+#include <sstream>
+#include <stack>
#include <stdexcept>
#include <string>
-#include <vector>
#include <utility>
-#include <sstream>
+#include <vector>
-#if defined(_GLIBCXX_INCLUDE_AS_CXX0X)
-# include <tr1_impl/regex>
-#else
-# define _GLIBCXX_INCLUDE_AS_CXX0X
-# define _GLIBCXX_BEGIN_NAMESPACE_TR1
-# define _GLIBCXX_END_NAMESPACE_TR1
-# define _GLIBCXX_TR1
-# include <tr1_impl/regex>
-# undef _GLIBCXX_TR1
-# undef _GLIBCXX_END_NAMESPACE_TR1
-# undef _GLIBCXX_BEGIN_NAMESPACE_TR1
-# undef _GLIBCXX_INCLUDE_AS_CXX0X
-#endif
+#include <bits/regex_constants.h>
+#include <bits/regex_error.h>
+#include <bits/regex_cursor.h>
+#include <bits/regex_nfa.h>
+#include <bits/regex_compiler.h>
+#include <bits/regex_grep_matcher.h>
+#include <bits/regex.h>
#endif // __GXX_EXPERIMENTAL_CXX0X__
diff --git a/libstdc++-v3/testsuite/28_regex/03_requirements/typedefs.cc b/libstdc++-v3/testsuite/28_regex/03_requirements/typedefs.cc
new file mode 100644
index 00000000000..072d5d07f40
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/03_requirements/typedefs.cc
@@ -0,0 +1,38 @@
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+//
+// 2010-02-17 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.3 Requirements [re.req]
+// 28.2 (4) Table 127 - Regular expression traits class requirements
+
+#include <regex>
+
+void
+test01()
+{
+ typedef std::regex_traits<char> traits;
+
+ typedef traits::char_type char_type;
+ typedef traits::string_type string_type;
+ typedef traits::locale_type locale_type;
+ typedef traits::char_class_type char_class_type;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/04_header/regex/std_c++0x_neg.cc b/libstdc++-v3/testsuite/28_regex/04_header/regex/std_c++0x_neg.cc
new file mode 100644
index 00000000000..e8ddb77bbb3
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/04_header/regex/std_c++0x_neg.cc
@@ -0,0 +1,23 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++98" }
+
+// Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <regex> // { dg-excess-errors "In file included from" }
+
+
diff --git a/libstdc++-v3/testsuite/28_regex/05_constants/error_type.cc b/libstdc++-v3/testsuite/28_regex/05_constants/error_type.cc
new file mode 100644
index 00000000000..1841a462688
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/05_constants/error_type.cc
@@ -0,0 +1,54 @@
+// { dg-options "-std=c++0x" }
+// { dg-do compile }
+//
+// 2009-06-17 Stephen M. Webb <stephen.webb@xandros.com>
+//
+// Copyright (C) 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.5.3
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::regex_constants::error_type err __attribute__((unused));
+
+ err = std::regex_constants::error_collate;
+ err = std::regex_constants::error_ctype;
+ err = std::regex_constants::error_escape;
+ err = std::regex_constants::error_backref;
+ err = std::regex_constants::error_brack;
+ err = std::regex_constants::error_paren;
+ err = std::regex_constants::error_brace;
+ err = std::regex_constants::error_badbrace;
+ err = std::regex_constants::error_range;
+ err = std::regex_constants::error_space;
+ err = std::regex_constants::error_badrepeat;
+ err = std::regex_constants::error_complexity;
+ err = std::regex_constants::error_stack;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/05_constants/match_flag_type.cc b/libstdc++-v3/testsuite/28_regex/05_constants/match_flag_type.cc
new file mode 100644
index 00000000000..10635ff5f7f
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/05_constants/match_flag_type.cc
@@ -0,0 +1,53 @@
+// { dg-options "-std=c++0x" }
+// { dg-do compile }
+//
+// 2009-06-17 Stephen M. Webb <stephen.webb@xandros.com>
+//
+// Copyright (C) 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.5.1
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::regex_constants::match_flag_type flag = std::regex_constants::match_default;
+
+ flag |= std::regex_constants::match_not_bol;
+ flag |= std::regex_constants::match_not_eol;
+ flag |= std::regex_constants::match_not_bow;
+ flag |= std::regex_constants::match_not_eow;
+ flag |= std::regex_constants::match_any;
+ flag |= std::regex_constants::match_not_null;
+ flag |= std::regex_constants::match_continuous;
+ flag |= std::regex_constants::match_prev_avail;
+ flag |= std::regex_constants::format_default;
+ flag |= std::regex_constants::format_sed;
+ flag |= std::regex_constants::format_no_copy;
+ flag |= std::regex_constants::format_first_only;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/05_constants/syntax_option_type.cc b/libstdc++-v3/testsuite/28_regex/05_constants/syntax_option_type.cc
new file mode 100644
index 00000000000..2aebf46d19e
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/05_constants/syntax_option_type.cc
@@ -0,0 +1,51 @@
+// { dg-options "-std=c++0x" }
+// { dg-do compile }
+//
+// 2009-06-17 Stephen M. Webb <stephen.webb@xandros.com>
+//
+// Copyright (C) 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.5.1
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::regex_constants::syntax_option_type option = 0;
+
+ option |= std::regex_constants::icase;
+ option |= std::regex_constants::nosubs;
+ option |= std::regex_constants::optimize;
+ option |= std::regex_constants::collate;
+ option |= std::regex_constants::ECMAScript;
+ option |= std::regex_constants::basic;
+ option |= std::regex_constants::extended;
+ option |= std::regex_constants::awk;
+ option |= std::regex_constants::grep;
+ option |= std::regex_constants::egrep;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/06_exception_type/regex_error.cc b/libstdc++-v3/testsuite/28_regex/06_exception_type/regex_error.cc
new file mode 100644
index 00000000000..04fd7124277
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/06_exception_type/regex_error.cc
@@ -0,0 +1,49 @@
+// { dg-options "-std=c++0x" }
+// { dg-do compile }
+//
+// 2009-06-17 Stephen M. Webb <stephen.webb@xandros.com>
+//
+// Copyright (C) 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.6 [re.badexp]
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::regex_error error(std::regex_constants::error_collate);
+ VERIFY(error.code() == std::regex_constants::error_collate);
+
+ try
+ {
+ throw error;
+ }
+ catch (std::runtime_error& ex)
+ {
+ }
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/07_traits/char/ctor.cc b/libstdc++-v3/testsuite/28_regex/07_traits/char/ctor.cc
new file mode 100644
index 00000000000..6f5a2f3ab8d
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/07_traits/char/ctor.cc
@@ -0,0 +1,50 @@
+// { dg-do link }
+// { dg-options "-std=gnu++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// [28.7] class template regex_traits
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+// Tests default constructor of the regex_traits class. There is only the
+// default constructor.
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::regex_traits<char> test_type;
+
+ // required default constructor
+ test_type t;
+
+ // Check for required typedefs
+ typedef test_type::char_type char_type;
+ typedef test_type::string_type string_type;
+ typedef test_type::locale_type locale_type;
+ typedef test_type::char_class_type char_class_type;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/07_traits/char/isctype.cc b/libstdc++-v3/testsuite/28_regex/07_traits/char/isctype.cc
new file mode 100644
index 00000000000..cb8664ca8bf
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/07_traits/char/isctype.cc
@@ -0,0 +1,48 @@
+// { dg-do run { xfail *-*-* } }
+// { dg-options "-std=c++0x" }
+
+//
+// 2010-06-23 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.3 Requirements [re.req]
+// 28.2(4) Table 127 - Regular expression traits class requirements
+// 28.7(11) Class template regex_traits [re.traits]
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef char CharT;
+ typedef std::regex_traits<CharT> traits;
+
+ char name[] = "lower";
+ traits t;
+
+ VERIFY( t.isctype('e', t.lookup_classname(name, name+sizeof(name)-1)) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/07_traits/char/length.cc b/libstdc++-v3/testsuite/28_regex/07_traits/char/length.cc
new file mode 100644
index 00000000000..55406dd0ded
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/07_traits/char/length.cc
@@ -0,0 +1,49 @@
+// { dg-do run }
+// { dg-options "-std=c++0x" }
+
+//
+// 2010-02-17 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.3 Requirements [re.req]
+// 28.2 (4) Table 127 - Regular expression traits class requirements
+// 28.7 Class template regex_traits [re.traits]
+// 28.7 (3) static std::size_t length(const char_type* p);
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ typedef char CharT;
+ typedef std::regex_traits<CharT> traits;
+ bool test __attribute__((unused)) = true;
+ const CharT* p = "";
+
+ std::size_t i = traits::length(p);
+
+ VERIFY( i == 0 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/07_traits/char/lookup_classname.cc b/libstdc++-v3/testsuite/28_regex/07_traits/char/lookup_classname.cc
new file mode 100644
index 00000000000..49ffb511add
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/07_traits/char/lookup_classname.cc
@@ -0,0 +1,54 @@
+// { dg-do run { xfail *-*-* } }
+// { dg-options "-std=c++0x" }
+
+//
+// 2010-06-23 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.3 Requirements [re.req]
+// 28.2(4) Table 127 - Regular expression traits class requirements
+// 28.7(9) Class template regex_traits [re.traits]
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef char CharT;
+ typedef std::regex_traits<CharT> traits;
+
+ char n1[] = "lower";
+ char n2[] = "alpha";
+ traits t;
+
+ traits::char_class_type c1 = t.lookup_classname(n1, n1+sizeof(n1)-1);
+ VERIFY( c1 != 0 );
+
+ traits::char_class_type c2 = t.lookup_classname(n1, n1+sizeof(n1)-1, true);
+ traits::char_class_type c3 = t.lookup_classname(n2, n2+sizeof(n2)-1, true);
+ VERIFY( c2 == c3 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/07_traits/char/lookup_collatename.cc b/libstdc++-v3/testsuite/28_regex/07_traits/char/lookup_collatename.cc
new file mode 100644
index 00000000000..58eb5878de5
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/07_traits/char/lookup_collatename.cc
@@ -0,0 +1,50 @@
+// { dg-do run { xfail *-*-* } }
+// { dg-options "-std=c++0x" }
+
+//
+// 2010-06-23 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.3 Requirements [re.req]
+// 28.2 (4) Table 127 - Regular expression traits class requirements
+// 28.7 (8) Class template regex_traits [re.traits]
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef char CharT;
+ typedef std::regex_traits<CharT> traits;
+
+ char name[] = "ll";
+ traits t;
+
+ traits::string_type sname = t.lookup_collatename(name, name+sizeof(name)-1);
+
+ VERIFY( !sname.empty() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/07_traits/char/transform.cc b/libstdc++-v3/testsuite/28_regex/07_traits/char/transform.cc
new file mode 100644
index 00000000000..1481dcfbb8c
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/07_traits/char/transform.cc
@@ -0,0 +1,51 @@
+// { dg-do run }
+// { dg-options "-std=c++0x" }
+
+//
+// 2010-02-17 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.3 Requirements [re.req]
+// 28.2 (4) Table 127 - Regular expression traits class requirements
+// 28.7 Class template regex_traits [re.traits]
+
+#include <regex>
+#include <string>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef char CharT;
+ typedef std::regex_traits<CharT> traits;
+
+ traits t;
+ traits::string_type G = "abc";
+ traits::string_type H = "def";
+
+ VERIFY( G < H );
+ VERIFY( t.transform(G.begin(), G.end()) < t.transform(H.begin(), H.end()) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/07_traits/char/transform_primary.cc b/libstdc++-v3/testsuite/28_regex/07_traits/char/transform_primary.cc
new file mode 100644
index 00000000000..7de8904b49a
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/07_traits/char/transform_primary.cc
@@ -0,0 +1,55 @@
+// { dg-options "-std=c++0x" }
+// { dg-do run { xfail *-*-* } }
+
+//
+// 2010-02-17 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.3 Requirements [re.req]
+// 28.2 (4) Table 127 - Regular expression traits class requirements
+// 28.7 Class template regex_traits [re.traits]
+
+#include <regex>
+#include <string>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef char CharT;
+ typedef std::regex_traits<CharT> traits;
+
+ traits t;
+ traits::string_type G = "abc";
+ traits::string_type H = "def";
+ traits::string_type J = "ABC";
+
+ VERIFY( G < H );
+ VERIFY( t.transform_primary(G.begin(), G.end()) < t.transform_primary(H.begin(), H.end()) );
+
+ VERIFY( G == H );
+ VERIFY( t.transform_primary(G.begin(), G.end()) == t.transform_primary(J.begin(), J.end()) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/07_traits/char/translate.cc b/libstdc++-v3/testsuite/28_regex/07_traits/char/translate.cc
new file mode 100644
index 00000000000..2dbbba39637
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/07_traits/char/translate.cc
@@ -0,0 +1,49 @@
+// { dg_do run }
+// { dg-options "-std=c++0x" }
+
+//
+// 2010-02-17 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.3 Requirements [re.req]
+// 28.2 (4) Table 127 - Regular expression traits class requirements
+// 28.7 Class template regex_traits [re.traits]
+// 28.7 (3) static std::size_t length(const char_type* p);
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef char CharT;
+
+ std::regex_traits<CharT> t;
+ CharT c = 'a';
+ CharT d = 'a';
+
+ VERIFY( t.translate(c) == t.translate(d) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/07_traits/char/translate_nocase.cc b/libstdc++-v3/testsuite/28_regex/07_traits/char/translate_nocase.cc
new file mode 100644
index 00000000000..4c963ddd3a5
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/07_traits/char/translate_nocase.cc
@@ -0,0 +1,46 @@
+// { dg-do run }
+// { dg-options "-std=gnu++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// [28.7] class template regex_traits (5) translate_nocase
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+// Verifies the workings of the regex_traits translate_nocase function.
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef char CharT;
+
+ std::regex_traits<CharT> t;
+ CharT c = 'a';
+ CharT C = 'A';
+
+ VERIFY( t.translate_nocase(c) == t.translate_nocase(C) );
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/07_traits/char/value.cc b/libstdc++-v3/testsuite/28_regex/07_traits/char/value.cc
new file mode 100644
index 00000000000..f0535acb2cc
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/07_traits/char/value.cc
@@ -0,0 +1,49 @@
+// { dg-do run }
+// { dg-options "-std=gnu++0x" }
+
+// 2008-08-11 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// [28.7] class template regex_traits value() function
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+// Tests the value() function of the regex_traits<char> class.
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ std::regex_traits<char> t;
+ VERIFY( t.value('7', 8) == 7 );
+ VERIFY( t.value('7', 10) == 7 );
+ VERIFY( t.value('7', 16) == 7 );
+ VERIFY( t.value('9', 8) == -1 );
+ VERIFY( t.value('9', 10) == 9 );
+ VERIFY( t.value('9', 16) == 9 );
+ VERIFY( t.value('d', 8) == -1 );
+ VERIFY( t.value('d', 10) == -1 );
+ VERIFY( t.value('d', 16) == 13 );
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/07_traits/wchar_t/ctor.cc b/libstdc++-v3/testsuite/28_regex/07_traits/wchar_t/ctor.cc
new file mode 100644
index 00000000000..39caf432d32
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/07_traits/wchar_t/ctor.cc
@@ -0,0 +1,49 @@
+// { dg-do link }
+// { dg-options "-std=gnu++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// [28.7] class template regex_traits
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+// Tests default constructor of the regex_traits class. There is only the
+// default constructor.
+void test01()
+{
+ typedef std::regex_traits<wchar_t> test_type;
+
+ // required default constructor
+ test_type t;
+
+ // Check for required typedefs
+ typedef test_type::char_type char_type;
+ typedef test_type::string_type string_type;
+ typedef test_type::locale_type locale_type;
+ typedef test_type::char_class_type char_class_type;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/07_traits/wchar_t/length.cc b/libstdc++-v3/testsuite/28_regex/07_traits/wchar_t/length.cc
new file mode 100644
index 00000000000..c3cd7b60d0c
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/07_traits/wchar_t/length.cc
@@ -0,0 +1,49 @@
+// { dg-do run }
+// { dg-options "-std=c++0x" }
+
+//
+// 2010-02-17 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.3 Requirements [re.req]
+// 28.2 (4) Table 127 - Regular expression traits class requirements
+// 28.7 Class template regex_traits [re.traits]
+// 28.7 (3) static std::size_t length(const char_type* p);
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ typedef wchar_t CharT;
+ typedef std::regex_traits<CharT> traits;
+ bool test __attribute__((unused)) = true;
+ const CharT* p = L"";
+
+ std::size_t i = traits::length(p);
+
+ VERIFY( i == 0 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/07_traits/wchar_t/transform.cc b/libstdc++-v3/testsuite/28_regex/07_traits/wchar_t/transform.cc
new file mode 100644
index 00000000000..c1f7af44d71
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/07_traits/wchar_t/transform.cc
@@ -0,0 +1,51 @@
+// { dg-do run }
+// { dg-options "-std=c++0x" }
+
+//
+// 2010-02-17 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.3 Requirements [re.req]
+// 28.2 (4) Table 127 - Regular expression traits class requirements
+// 28.7 Class template regex_traits [re.traits]
+
+#include <regex>
+#include <string>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef wchar_t CharT;
+ typedef std::regex_traits<CharT> traits;
+
+ traits t;
+ traits::string_type G = L"abc";
+ traits::string_type H = L"def";
+
+ VERIFY( G < H );
+ VERIFY( t.transform(G.begin(), G.end()) < t.transform(H.begin(), H.end()) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/07_traits/wchar_t/translate.cc b/libstdc++-v3/testsuite/28_regex/07_traits/wchar_t/translate.cc
new file mode 100644
index 00000000000..962c381520c
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/07_traits/wchar_t/translate.cc
@@ -0,0 +1,49 @@
+// { dg-do run }
+// { dg-options "-std=c++0x" }
+
+//
+// 2010-02-17 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.3 Requirements [re.req]
+// 28.2 (4) Table 127 - Regular expression traits class requirements
+// 28.7 Class template regex_traits [re.traits]
+// 28.7 (3) static std::size_t length(const char_type* p);
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef wchar_t CharT;
+
+ std::regex_traits<CharT> t;
+ CharT c = L'a';
+ CharT d = L'a';
+
+ VERIFY( t.translate(c) == t.translate(d) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/07_traits/wchar_t/translate_nocase.cc b/libstdc++-v3/testsuite/28_regex/07_traits/wchar_t/translate_nocase.cc
new file mode 100644
index 00000000000..5602cf00117
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/07_traits/wchar_t/translate_nocase.cc
@@ -0,0 +1,46 @@
+// { dg-do run }
+// { dg-options "-std=gnu++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// [28.7] class template regex_traits (5) translate_nocase
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+// Verifies the workings of the regex_traits translate_nocase function.
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef wchar_t CharT;
+
+ std::regex_traits<CharT> t;
+ CharT c = L'a';
+ CharT C = L'A';
+
+ VERIFY( t.translate_nocase(c) == t.translate_nocase(C) );
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/07_traits/wchar_t/value.cc b/libstdc++-v3/testsuite/28_regex/07_traits/wchar_t/value.cc
new file mode 100644
index 00000000000..f0535acb2cc
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/07_traits/wchar_t/value.cc
@@ -0,0 +1,49 @@
+// { dg-do run }
+// { dg-options "-std=gnu++0x" }
+
+// 2008-08-11 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// [28.7] class template regex_traits value() function
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+// Tests the value() function of the regex_traits<char> class.
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ std::regex_traits<char> t;
+ VERIFY( t.value('7', 8) == 7 );
+ VERIFY( t.value('7', 10) == 7 );
+ VERIFY( t.value('7', 16) == 7 );
+ VERIFY( t.value('9', 8) == -1 );
+ VERIFY( t.value('9', 10) == 9 );
+ VERIFY( t.value('9', 16) == 9 );
+ VERIFY( t.value('d', 8) == -1 );
+ VERIFY( t.value('d', 10) == -1 );
+ VERIFY( t.value('d', 16) == 13 );
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/char/cstring.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/char/cstring.cc
new file mode 100644
index 00000000000..1552818e987
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/char/cstring.cc
@@ -0,0 +1,44 @@
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+// 2009-06-05 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// C++0X [28.8.3] class template basic_regex assign()
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+// Tests assign operation from a C-style null-terminated-string.
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::basic_regex<char> re;
+
+ const char* cs = "aab";
+ re.assign(cs);
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/char/cstring_op.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/char/cstring_op.cc
new file mode 100644
index 00000000000..12353023b38
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/char/cstring_op.cc
@@ -0,0 +1,43 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// [28.8.3] class template basic_regex assign()
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+// Tests basic_regex assign operator from a C-style null-terminated-string.
+void test01()
+{
+ typedef std::basic_regex<char> test_type;
+
+ const char* cs = "aab";
+ test_type re;
+ re = cs;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/char/moveable.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/char/moveable.cc
new file mode 100644
index 00000000000..64f5bcac570
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/char/moveable.cc
@@ -0,0 +1,50 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2010-07-07 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// [28.8.3](9-11) class template basic_regex assign
+
+#include <regex>
+#include <testsuite_hooks.h>
+#include <utility>
+
+// Tests assign operator of the basic_regex class for moveable rvalues.
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::regex src_re("aaba");
+ const unsigned mark_count = src_re.mark_count();
+ const std::regex::flag_type flags = src_re.flags();
+
+ std::regex target_re;
+
+ target_re.assign(std::move(src_re));
+
+ VERIFY( target_re.flags() == flags );
+ VERIFY( target_re.mark_count() == mark_count );
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/char/pstring.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/char/pstring.cc
new file mode 100644
index 00000000000..398b66c6063
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/char/pstring.cc
@@ -0,0 +1,43 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// [28.8.3] class template basic_regex assign()
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+// Tests assign operation from a Pascal-style counted-string.
+void test01()
+{
+ typedef std::basic_regex<char> test_type;
+
+ const char cs[] = "aab";
+ test_type re;
+ re.assign(cs, sizeof(cs)-1, std::regex_constants::basic);
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/char/range.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/char/range.cc
new file mode 100644
index 00000000000..cd741d5fff2
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/char/range.cc
@@ -0,0 +1,43 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// [28.8.3] class template basic_regex assign()
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+// Tests range assign of the basic_regex class.
+void test01()
+{
+ typedef std::basic_regex<char> test_type;
+
+ char s[] = "a+b|c";
+ test_type re;
+ re.assign(s, s + 5);
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/char/string.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/char/string.cc
new file mode 100644
index 00000000000..afa071eb312
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/char/string.cc
@@ -0,0 +1,44 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// [28.8.3] class template basic_regex assign()
+
+#include <string>
+#include <regex>
+#include <testsuite_hooks.h>
+
+// Tests C++ string assignment of the basic_regex class.
+void test01()
+{
+ typedef std::basic_regex<char> test_type;
+
+ std::string s("a*b");
+ test_type re;
+ re.assign(s);
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/char/string_op.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/char/string_op.cc
new file mode 100644
index 00000000000..724872decd5
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/char/string_op.cc
@@ -0,0 +1,44 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// [28.8.3] class template basic_regex assign()
+
+#include <string>
+#include <regex>
+#include <testsuite_hooks.h>
+
+// Tests basic_regex assignment operator from a C++ string;
+void test01()
+{
+ typedef std::basic_regex<char> test_type;
+
+ std::string s("a*b");
+ test_type re;
+ re = s;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/wchar_t/cstring.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/wchar_t/cstring.cc
new file mode 100644
index 00000000000..20ccab01244
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/wchar_t/cstring.cc
@@ -0,0 +1,44 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// [28.8.3] class template basic_regex assign()
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+// Tests assign operation from a C-style null-terminated-string.
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::basic_regex<wchar_t> test_type;
+
+ const wchar_t* cs = L"aab";
+ test_type re;
+ re.assign(cs);
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/wchar_t/cstring_op.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/wchar_t/cstring_op.cc
new file mode 100644
index 00000000000..8d8e9656d9e
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/wchar_t/cstring_op.cc
@@ -0,0 +1,44 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// [28.8.3] class template basic_regex assign()
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+// Tests basic_regex assign operator from a C-style null-terminated-string.
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::basic_regex<wchar_t> test_type;
+
+ const wchar_t* cs = L"aab";
+ test_type re;
+ re = cs;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/wchar_t/pstring.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/wchar_t/pstring.cc
new file mode 100644
index 00000000000..9034a542c01
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/wchar_t/pstring.cc
@@ -0,0 +1,43 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// [28.8.3] class template basic_regex assign()
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+// Tests assign operation from a Pascal-style counted-string.
+void test01()
+{
+ typedef std::basic_regex<wchar_t> test_type;
+
+ const wchar_t cs[] = L"aab";
+ test_type re;
+ re.assign(cs, sizeof(cs)-1, std::regex_constants::basic);
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/wchar_t/range.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/wchar_t/range.cc
new file mode 100644
index 00000000000..2e31a708417
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/wchar_t/range.cc
@@ -0,0 +1,44 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// [28.8.3] class template basic_regex assign()
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+// Tests range assign of the basic_regex class.
+void test01()
+{
+ typedef std::basic_regex<wchar_t> test_type;
+ bool test __attribute__((unused)) = true;
+
+ wchar_t s[] = L"a+b|c";
+ test_type re;
+ re.assign(s, s + 5);
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/wchar_t/string.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/wchar_t/string.cc
new file mode 100644
index 00000000000..156374ac1a7
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/wchar_t/string.cc
@@ -0,0 +1,45 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// [28.8.3] class template basic_regex assign()
+
+#include <string>
+#include <regex>
+#include <testsuite_hooks.h>
+
+// Tests C++ string assignment of the basic_regex class.
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::basic_regex<wchar_t> test_type;
+
+ std::wstring s(L"a*b");
+ test_type re;
+ re.assign(s);
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/wchar_t/string_op.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/wchar_t/string_op.cc
new file mode 100644
index 00000000000..43704af2bd1
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/assign/wchar_t/string_op.cc
@@ -0,0 +1,45 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// [28.8.3] class template basic_regex assign()
+
+#include <string>
+#include <regex>
+#include <testsuite_hooks.h>
+
+// Tests basic_regex assignment operator from a C++ string;
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::basic_regex<wchar_t> test_type;
+
+ std::wstring s(L"a*b");
+ test_type re;
+ re = s;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/basic/cstring.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/basic/cstring.cc
new file mode 100644
index 00000000000..b91453c0e77
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/basic/cstring.cc
@@ -0,0 +1,37 @@
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2007, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 7.8.2 basic_regex constructors
+
+#include <regex>
+
+void
+test01()
+{
+ std::regex re("(a|b)*abb", std::regex::basic);
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/basic/pstring_char.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/basic/pstring_char.cc
new file mode 100644
index 00000000000..2f011fe52c4
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/basic/pstring_char.cc
@@ -0,0 +1,42 @@
+// { dg-do run }
+// { dg-options "-std=gnu++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// [28.8.2] class template basic_regex constructor
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+// Tests Pascal-style counted-string constructor of the basic_regex class.
+void test01()
+{
+ const char* cs = "aab";
+ std::regex re(cs, 3, std::regex::basic);
+
+ VERIFY( re.flags() & std::regex_constants::basic );
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/basic/pstring_wchar_t.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/basic/pstring_wchar_t.cc
new file mode 100644
index 00000000000..89deef6f19f
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/basic/pstring_wchar_t.cc
@@ -0,0 +1,44 @@
+// { dg-do run }
+// { dg-options "-std=c++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// [28.8.2] class template basic_regex constructor
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+// Tests Pascal-style counted-string constructor of the basic_regex class.
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ const wchar_t* cs = L"aab";
+ std::wregex re(cs, 3, std::wregex::basic);
+
+ VERIFY( re.flags() & std::regex_constants::basic );
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/basic/string_range_01_02_03.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/basic/string_range_01_02_03.cc
new file mode 100644
index 00000000000..471c89c9024
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/basic/string_range_01_02_03.cc
@@ -0,0 +1,52 @@
+// { dg-options "-std=c++0x" }
+// { dg-do run { xfail *-*-* } }
+
+//
+// 2010-06-16 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.8.2 basic_regex ctor
+// Tests for invalid range expression
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ try
+ {
+ std::regex re("a\\{1,2,3\\}", std::regex::basic);
+ }
+ catch (std::regex_error& ex)
+ {
+ VERIFY( ex.code() == std::regex_constants::error_badbrace );
+ }
+}
+
+
+int
+main()
+{
+ test01();
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/char/cstring.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/char/cstring.cc
new file mode 100644
index 00000000000..ac87e4d69a0
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/char/cstring.cc
@@ -0,0 +1,42 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// [28.8.2] class template basic_regex constructor
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+// Tests C-style null-terminated-string constructor of the basic_regex class.
+void test01()
+{
+ typedef std::basic_regex<char> test_type;
+
+ const char* cs = "aab";
+ test_type re(cs);
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/char/cstring_awk.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/char/cstring_awk.cc
new file mode 100644
index 00000000000..8b93fe7a721
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/char/cstring_awk.cc
@@ -0,0 +1,37 @@
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2007, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 7.8.2 basic_regex constructors
+
+#include <regex>
+
+void
+test01()
+{
+ std::regex re("(a|b)*abb", std::regex::awk);
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/char/cstring_ecma.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/char/cstring_ecma.cc
new file mode 100644
index 00000000000..6c72736c5cd
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/char/cstring_ecma.cc
@@ -0,0 +1,37 @@
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2007, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 7.8.2 basic_regex constructors
+
+#include <regex>
+
+void
+test01()
+{
+ std::regex re("(a|b)*abb");
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/char/cstring_egrep.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/char/cstring_egrep.cc
new file mode 100644
index 00000000000..f38a9b8704e
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/char/cstring_egrep.cc
@@ -0,0 +1,37 @@
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2007, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 7.8.2 basic_regex constructors
+
+#include <regex>
+
+void
+test01()
+{
+ std::regex re("(a|b)*abb", std::regex::egrep);
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/char/cstring_grep.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/char/cstring_grep.cc
new file mode 100644
index 00000000000..458f6d21cc5
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/char/cstring_grep.cc
@@ -0,0 +1,39 @@
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2007, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 7.8.2 basic_regex constructors
+
+#include <regex>
+
+void
+test01()
+{
+ using std::regex;
+
+ regex re("(a|b)*abb", regex::grep);
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/char/default.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/char/default.cc
new file mode 100644
index 00000000000..b7c6f410cde
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/char/default.cc
@@ -0,0 +1,47 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// [28.8.2] class template basic_regex constructor
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+// Tests default constructor of the basic_regex class.
+void test01()
+{
+ typedef std::basic_regex<char> test_type;
+
+ // default constructor
+ test_type re;
+
+ // Check for required typedefs
+ typedef test_type::value_type value_type;
+ typedef test_type::flag_type flag_type;
+ typedef test_type::locale_type locale_type;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/char/range.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/char/range.cc
new file mode 100644
index 00000000000..027a927849e
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/char/range.cc
@@ -0,0 +1,42 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// [28.8.2] class template basic_regex constructor
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+// Tests range constructor of the basic_regex class.
+void test01()
+{
+ typedef std::basic_regex<char> test_type;
+
+ char s[] = "a+b|c";
+ test_type re(s, s + 5);
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/copy_char.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/copy_char.cc
new file mode 100644
index 00000000000..4ed5f92c8b0
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/copy_char.cc
@@ -0,0 +1,45 @@
+// { dg-options "-std=c++0x" }
+
+// 2010-07-07 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// [28.8.2](11) class template basic_regex constructors
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+// Tests copy constructor of the basic_regex class.
+void test01()
+{
+ typedef std::basic_regex<char> test_type;
+
+ test_type src_re("aaba");
+
+ test_type target_re(src_re);
+
+ VERIFY( target_re.flags() == src_re.flags() );
+ VERIFY( target_re.mark_count() == src_re.mark_count() );
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/extended/cstring.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/extended/cstring.cc
new file mode 100644
index 00000000000..691b8c7f5f1
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/extended/cstring.cc
@@ -0,0 +1,43 @@
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2007, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 7.8.2 basic_regex constructors
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::regex re("(wee|week)(knights|night)", std::regex::extended);
+
+ VERIFY( re.flags() == std::regex::extended );
+ VERIFY( re.mark_count() == 0 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/extended/string_range_01_02_03.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/extended/string_range_01_02_03.cc
new file mode 100644
index 00000000000..036321face5
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/extended/string_range_01_02_03.cc
@@ -0,0 +1,52 @@
+// { dg-options "-std=c++0x" }
+// { dg-do run { xfail *-*-* } }
+
+//
+// 2010-06-16 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.8.2 basic_regex ctor
+// Tests for invalid range expression
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ try
+ {
+ std::regex re("a{1,2,3}", std::regex::extended);
+ }
+ catch (std::regex_error& ex)
+ {
+ VERIFY( ex.code() == std::regex_constants::error_badbrace );
+ }
+}
+
+
+int
+main()
+{
+ test01();
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/move_char.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/move_char.cc
new file mode 100644
index 00000000000..ba056969c5c
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/move_char.cc
@@ -0,0 +1,49 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2010-07-07 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// [28.8.2](12-14) class template basic_regex constructors
+
+#include <regex>
+#include <testsuite_hooks.h>
+#include <utility>
+
+// Tests move constructor of the basic_regex class.
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::basic_regex<char> test_type;
+
+ test_type src_re("aaba");
+ const unsigned mark_count = src_re.mark_count();
+ const test_type::flag_type flags = src_re.flags();
+
+ test_type target_re = std::move(src_re);
+
+ VERIFY( target_re.flags() == flags );
+ VERIFY( target_re.mark_count() == mark_count );
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/string_char.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/string_char.cc
new file mode 100644
index 00000000000..f65d783a735
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/string_char.cc
@@ -0,0 +1,54 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// [28.8.2] class template basic_regex constructor
+
+#include <string>
+#include <regex>
+#include <testsuite_hooks.h>
+#include <testsuite_allocator.h>
+
+// Tests C++ string constructor of the basic_regex class.
+void test01()
+{
+ typedef std::basic_regex<char> test_type;
+
+ std::string s("a*b");
+ test_type re(s);
+}
+
+void test02()
+{
+ typedef std::basic_regex<char> test_type;
+ typedef __gnu_test::tracker_allocator<char> alloc_type;
+
+ std::basic_string<char, std::char_traits<char>, alloc_type> s("a*b");
+ test_type re(s);
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/string_wchar_t.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/string_wchar_t.cc
new file mode 100644
index 00000000000..b715195c383
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/string_wchar_t.cc
@@ -0,0 +1,56 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// [28.8.2] class template basic_regex constructor
+
+#include <string>
+#include <regex>
+#include <testsuite_hooks.h>
+#include <testsuite_allocator.h>
+
+// Tests C++ string constructor of the basic_regex class.
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::basic_regex<wchar_t> test_type;
+
+ std::wstring s(L"a*b");
+ test_type re(s);
+}
+
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::basic_regex<wchar_t> test_type;
+ typedef __gnu_test::tracker_allocator<wchar_t> alloc_type;
+
+ std::basic_string<wchar_t, std::char_traits<wchar_t>, alloc_type> s(L"a*b");
+ test_type re(s);
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/wchar_t/cstring.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/wchar_t/cstring.cc
new file mode 100644
index 00000000000..4dabf399677
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/wchar_t/cstring.cc
@@ -0,0 +1,43 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// [28.8.2] class template basic_regex constructor
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+// Tests C-style null-terminated-string constructor of the basic_regex class.
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::basic_regex<wchar_t> test_type;
+
+ const wchar_t* cs = L"aab";
+ test_type re(cs);
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/wchar_t/default.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/wchar_t/default.cc
new file mode 100644
index 00000000000..a0f41740229
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/wchar_t/default.cc
@@ -0,0 +1,48 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// [28.8.2] class template basic_regex constructor
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+// Tests default constructor of the basic_regex class.
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::basic_regex<wchar_t> test_type;
+
+ // default constructor
+ test_type re;
+
+ // Check for required typedefs
+ typedef test_type::value_type value_type;
+ typedef test_type::flag_type flag_type;
+ typedef test_type::locale_type locale_type;
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/wchar_t/range.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/wchar_t/range.cc
new file mode 100644
index 00000000000..efc0597cc1d
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/ctors/wchar_t/range.cc
@@ -0,0 +1,43 @@
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// [28.8.2] class template basic_regex constructor
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+// Tests range constructor of the basic_regex class.
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::basic_regex<wchar_t> test_type;
+
+ wchar_t s[] = L"a+b|c";
+ test_type re(s, s + 5);
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/08_basic_regex/regex.cc b/libstdc++-v3/testsuite/28_regex/08_basic_regex/regex.cc
new file mode 100644
index 00000000000..8a803ede81f
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/08_basic_regex/regex.cc
@@ -0,0 +1,37 @@
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+// 2007-03-12 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 7.4 typedef std::regex
+
+#include <regex>
+
+void
+test01()
+{
+ std::regex re;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/09_sub_match/cast_char.cc b/libstdc++-v3/testsuite/28_regex/09_sub_match/cast_char.cc
new file mode 100644
index 00000000000..6beb9c5cdb2
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/09_sub_match/cast_char.cc
@@ -0,0 +1,49 @@
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+//
+// 2010-06-09 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.9.1 [re.submatch.members] sub_match members
+
+#include <regex>
+#include <string>
+#include <testsuite_hooks.h>
+
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ typedef char value_type;
+ typedef std::basic_string<value_type> string_type;
+ typedef std::sub_match<value_type*> sub_match_type;
+ value_type test_data[] = "cabbage";
+
+ sub_match_type sm;
+ sm.first = test_data + 0;
+ sm.second = test_data + sizeof(test_data)/sizeof(value_type);
+ sm.matched = true;
+
+ string_type sm_string = sm;
+
+ VERIFY( sm_string == string_type(test_data) );
+}
diff --git a/libstdc++-v3/testsuite/28_regex/09_sub_match/cast_wchar_t.cc b/libstdc++-v3/testsuite/28_regex/09_sub_match/cast_wchar_t.cc
new file mode 100644
index 00000000000..6e29ac88c09
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/09_sub_match/cast_wchar_t.cc
@@ -0,0 +1,49 @@
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+//
+// 2010-06-09 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.9.1 [re.submatch.members] sub_match members
+
+#include <regex>
+#include <string>
+#include <testsuite_hooks.h>
+
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ typedef wchar_t value_type;
+ typedef std::basic_string<value_type> string_type;
+ typedef std::sub_match<value_type*> sub_match_type;
+ value_type test_data[] = L"cabbage";
+
+ sub_match_type sm;
+ sm.first = test_data + 0;
+ sm.second = test_data + sizeof(test_data)/sizeof(value_type);
+ sm.matched = true;
+
+ string_type sm_string = sm;
+
+ VERIFY( sm_string == string_type(test_data) );
+}
diff --git a/libstdc++-v3/testsuite/28_regex/09_sub_match/length.cc b/libstdc++-v3/testsuite/28_regex/09_sub_match/length.cc
new file mode 100644
index 00000000000..fc12b920ad9
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/09_sub_match/length.cc
@@ -0,0 +1,49 @@
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+//
+// 2010-06-09 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.9.1 [re.submatch.members] sub_match members
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ typedef std::sub_match<const char*> sm_t;
+ const char* test_data = "cabbage";
+ sm_t::difference_type test_len = 3;
+
+ sm_t sm1;
+ sm1.first = test_data + 0;
+ sm1.second = test_data + test_len;
+ sm1.matched = true;
+
+ sm_t sm2;
+ sm2.matched = false;
+
+ VERIFY( sm1.length() == test_len );
+ VERIFY( sm2.length() == 0 );
+}
diff --git a/libstdc++-v3/testsuite/28_regex/09_sub_match/typedefs.cc b/libstdc++-v3/testsuite/28_regex/09_sub_match/typedefs.cc
new file mode 100644
index 00000000000..c150da02dac
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/09_sub_match/typedefs.cc
@@ -0,0 +1,38 @@
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+//
+// 2010-06-07 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.9 Class template sub_match
+
+#include <regex>
+
+
+void
+test01()
+{
+ typedef std::sub_match<char*> sm;
+
+ typedef sm::value_type value_type;
+ typedef sm::difference_type difference_type;
+ typedef sm::iterator iterator;
+ typedef sm::string_type string_type;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/10_match_results/ctors/char/default.cc b/libstdc++-v3/testsuite/28_regex/10_match_results/ctors/char/default.cc
new file mode 100644
index 00000000000..4c897d7a4a0
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/10_match_results/ctors/char/default.cc
@@ -0,0 +1,52 @@
+// { dg-options "-std=c++0x" }
+
+// 2009-06-10 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// C++0X [28.10.1] class template match_results constructor
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+// Tests default constructor of the match_result class.
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::cmatch cm;
+ VERIFY( cm.size() == 0 );
+ VERIFY( cm.str() == std::cmatch::string_type() );
+}
+
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::smatch sm;
+ VERIFY( sm.size() == 0 );
+ VERIFY( sm.str() == std::smatch::string_type() );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/10_match_results/ctors/wchar_t/default.cc b/libstdc++-v3/testsuite/28_regex/10_match_results/ctors/wchar_t/default.cc
new file mode 100644
index 00000000000..f8b3d45e867
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/10_match_results/ctors/wchar_t/default.cc
@@ -0,0 +1,52 @@
+// { dg-options "-std=c++0x" }
+
+// 2009-06-05 Stephen M. Webb <stephen.webb@bregmasoft.com>
+//
+// Copyright (C) 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// C++0X [28.10.1] class template match_results constructor
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+// Tests default constructor of the match_result class.
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::wcmatch cm;
+ VERIFY( cm.size() == 0 );
+ VERIFY( cm.str() == std::wcmatch::string_type() );
+}
+
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::wsmatch sm;
+ VERIFY( sm.size() == 0 );
+ VERIFY( sm.str() == std::wsmatch::string_type() );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ return 0;
+};
diff --git a/libstdc++-v3/testsuite/28_regex/10_match_results/typedefs.cc b/libstdc++-v3/testsuite/28_regex/10_match_results/typedefs.cc
new file mode 100644
index 00000000000..02bdcdadb71
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/10_match_results/typedefs.cc
@@ -0,0 +1,44 @@
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+//
+// 2010-06-10 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.10 Class template sub_match
+
+#include <regex>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::match_results<char*> mr;
+
+ typedef mr::value_type value_type;
+ typedef mr::const_reference const_reference;
+ typedef mr::reference reference;
+ typedef mr::const_iterator const_iterator;
+ typedef mr::iterator iterator;
+ typedef mr::difference_type difference_type;
+ typedef mr::size_type size_type;
+ typedef mr::allocator_type allocator_type;
+ typedef mr::char_type char_type;
+ typedef mr::string_type string_type;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/basic/string_01.cc b/libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/basic/string_01.cc
new file mode 100644
index 00000000000..4a7161a7967
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/basic/string_01.cc
@@ -0,0 +1,63 @@
+// { dg-options "-std=c++0x" }
+
+//
+// 2010-06-11 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.11.2 regex_match
+// Tests BRE against a std::string target.
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::regex re("\\(a\\).*", std::regex::basic);
+ std::string target("aaba");
+ std::smatch m;
+
+ VERIFY( std::regex_match(target, m, re) );
+
+ VERIFY( m.size() == re.mark_count()+1 );
+ VERIFY( m.empty() == false );
+ VERIFY( m.prefix().first == target.begin() );
+ VERIFY( m.prefix().second == target.begin() );
+ VERIFY( m.prefix().matched == false );
+ VERIFY( m.suffix().first == target.end() );
+ VERIFY( m.suffix().second == target.end() );
+ VERIFY( m.suffix().matched == false );
+ VERIFY( m[0].first == target.begin() );
+ VERIFY( m[0].second == target.end() );
+ VERIFY( m[0].matched == true );
+ VERIFY( m[1].first == target.begin() );
+ VERIFY( m[1].second == target.begin()+1 );
+ VERIFY( m[1].matched == true );
+}
+
+
+int
+main()
+{
+ test01();
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/basic/string_range_00_03.cc b/libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/basic/string_range_00_03.cc
new file mode 100644
index 00000000000..6c0fdd76f2c
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/basic/string_range_00_03.cc
@@ -0,0 +1,60 @@
+// { dg-options "-std=c++0x" }
+
+//
+// 2010-06-16 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.11.2 regex_match
+// Tests BRE against a std::string target, exercising range {0,3}
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::regex re("a\\{0,3\\}", std::regex::basic);
+ std::string target("aa");
+ std::smatch m;
+
+ VERIFY( std::regex_match(target, m, re) );
+
+ VERIFY( m.size() == re.mark_count()+1 );
+ VERIFY( m.empty() == false );
+ VERIFY( m.prefix().first == target.begin() );
+ VERIFY( m.prefix().second == target.begin() );
+ VERIFY( m.prefix().matched == false );
+ VERIFY( m.suffix().first == target.end() );
+ VERIFY( m.suffix().second == target.end() );
+ VERIFY( m.suffix().matched == false );
+ VERIFY( m[0].first == target.begin() );
+ VERIFY( m[0].second == target.end() );
+ VERIFY( m[0].matched == true );
+}
+
+
+int
+main()
+{
+ test01();
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/basic/string_range_01_03.cc b/libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/basic/string_range_01_03.cc
new file mode 100644
index 00000000000..3439b544b63
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/basic/string_range_01_03.cc
@@ -0,0 +1,60 @@
+// { dg-options "-std=c++0x" }
+
+//
+// 2010-06-16 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.11.2 regex_match
+// Tests BRE against a std::string target, exercising range {1,3}
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::regex re("a\\{1,3\\}", std::regex::basic);
+ std::string target("aa");
+ std::smatch m;
+
+ VERIFY( std::regex_match(target, m, re) );
+
+ VERIFY( m.size() == re.mark_count()+1 );
+ VERIFY( m.empty() == false );
+ VERIFY( m.prefix().first == target.begin() );
+ VERIFY( m.prefix().second == target.begin() );
+ VERIFY( m.prefix().matched == false );
+ VERIFY( m.suffix().first == target.end() );
+ VERIFY( m.suffix().second == target.end() );
+ VERIFY( m.suffix().matched == false );
+ VERIFY( m[0].first == target.begin() );
+ VERIFY( m[0].second == target.end() );
+ VERIFY( m[0].matched == true );
+}
+
+
+int
+main()
+{
+ test01();
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/basic/string_range_02_03.cc b/libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/basic/string_range_02_03.cc
new file mode 100644
index 00000000000..dfd00a0f3d7
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/basic/string_range_02_03.cc
@@ -0,0 +1,61 @@
+// { dg-options "-std=c++0x" }
+// { dg-do run { xfail *-*-* } }
+
+//
+// 2010-06-16 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.11.2 regex_match
+// Tests BRE against a std::string target, exercising range {2,3}
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::regex re("a\\{2,3\\}", std::regex::basic);
+ std::string target("aa");
+ std::smatch m;
+
+ VERIFY( std::regex_match(target, m, re) );
+
+ VERIFY( m.size() == re.mark_count()+1 );
+ VERIFY( m.empty() == false );
+ VERIFY( m.prefix().first == target.begin() );
+ VERIFY( m.prefix().second == target.begin() );
+ VERIFY( m.prefix().matched == false );
+ VERIFY( m.suffix().first == target.end() );
+ VERIFY( m.suffix().second == target.end() );
+ VERIFY( m.suffix().matched == false );
+ VERIFY( m[0].first == target.begin() );
+ VERIFY( m[0].second == target.end() );
+ VERIFY( m[0].matched == true );
+}
+
+
+int
+main()
+{
+ test01();
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/extended/cstring_plus.cc b/libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/extended/cstring_plus.cc
new file mode 100644
index 00000000000..ad0f57e221d
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/extended/cstring_plus.cc
@@ -0,0 +1,65 @@
+// { dg-options "-std=c++0x" }
+// { dg-do run { xfail *-*-* } }
+
+//
+// 2010-06-21 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.11.2 regex_match
+// Tests ERE against a C-string target, plus-sign match.
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::regex re("(a+)", std::regex::extended);
+ const char target[] = "aa";
+ std::cmatch m;
+
+ VERIFY( std::regex_match(target, m, re) );
+
+ VERIFY( re.mark_count() == 1 );
+ VERIFY( m.size() == re.mark_count()+1 );
+ VERIFY( m.empty() == false );
+ VERIFY( m.prefix().first == target );
+ VERIFY( m.prefix().second == target );
+ VERIFY( m.prefix().matched == false );
+ VERIFY( m.suffix().first == target+sizeof(target) );
+ VERIFY( m.suffix().second == target+sizeof(target) );
+ VERIFY( m.suffix().matched == false );
+ VERIFY( m[0].first == target );
+ VERIFY( m[0].second == target+sizeof(target) );
+ VERIFY( m[0].matched == true );
+ VERIFY( m[1].first == target );
+ VERIFY( m[1].second == target+sizeof(target) );
+ VERIFY( m[1].matched == true );
+}
+
+
+int
+main()
+{
+ test01();
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/extended/cstring_questionmark.cc b/libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/extended/cstring_questionmark.cc
new file mode 100644
index 00000000000..21abea456a9
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/extended/cstring_questionmark.cc
@@ -0,0 +1,65 @@
+// { dg-options "-std=c++0x" }
+// { dg-do run { xfail *-*-* } }
+
+//
+// 2010-06-21 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.11.2 regex_match
+// Tests ERE against a C-string target, question-mark match.
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::regex re("(aa?)", std::regex::extended);
+ char target[] = "a";
+ std::cmatch m;
+
+ VERIFY( std::regex_match(target, m, re) );
+
+ VERIFY( re.mark_count() == 1 );
+ VERIFY( m.size() == re.mark_count()+1 );
+ VERIFY( m.empty() == false );
+ VERIFY( m.prefix().first == target );
+ VERIFY( m.prefix().second == target );
+ VERIFY( m.prefix().matched == false );
+ VERIFY( m.suffix().first == target+sizeof(target) );
+ VERIFY( m.suffix().second == target+sizeof(target) );
+ VERIFY( m.suffix().matched == false );
+ VERIFY( m[0].first == target );
+ VERIFY( m[0].second == target+sizeof(target) );
+ VERIFY( m[0].matched == true );
+ VERIFY( m[1].first == target );
+ VERIFY( m[1].second == target+sizeof(target) );
+ VERIFY( m[1].matched == true );
+}
+
+
+int
+main()
+{
+ test01();
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/extended/string_any.cc b/libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/extended/string_any.cc
new file mode 100644
index 00000000000..8d3716b1edf
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/extended/string_any.cc
@@ -0,0 +1,60 @@
+// { dg-options "-std=c++0x" }
+
+//
+// 2010-06-11 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.11.2 regex_match
+// Tests ERE against a std::string target.
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::regex re(".*", std::regex::extended);
+ std::string target("aaba");
+ std::smatch m;
+
+ VERIFY( std::regex_match(target, m, re) );
+
+ VERIFY( m.size() == re.mark_count()+1 );
+ VERIFY( m.empty() == false );
+ VERIFY( m.prefix().first == target.begin() );
+ VERIFY( m.prefix().second == target.begin() );
+ VERIFY( m.prefix().matched == false );
+ VERIFY( m.suffix().first == target.end() );
+ VERIFY( m.suffix().second == target.end() );
+ VERIFY( m.suffix().matched == false );
+ VERIFY( m[0].first == target.begin() );
+ VERIFY( m[0].second == target.end() );
+ VERIFY( m[0].matched == true );
+}
+
+
+int
+main()
+{
+ test01();
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/extended/string_range_00_03.cc b/libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/extended/string_range_00_03.cc
new file mode 100644
index 00000000000..a0a2e1fa9d8
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/extended/string_range_00_03.cc
@@ -0,0 +1,60 @@
+// { dg-options "-std=c++0x" }
+
+//
+// 2010-06-16 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.11.2 regex_match
+// Tests ERE against a std::string target, exercising range {0,3}
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::regex re("a{0,3}", std::regex::extended);
+ std::string target("aa");
+ std::smatch m;
+
+ VERIFY( std::regex_match(target, m, re) );
+
+ VERIFY( m.size() == re.mark_count()+1 );
+ VERIFY( m.empty() == false );
+ VERIFY( m.prefix().first == target.begin() );
+ VERIFY( m.prefix().second == target.begin() );
+ VERIFY( m.prefix().matched == false );
+ VERIFY( m.suffix().first == target.end() );
+ VERIFY( m.suffix().second == target.end() );
+ VERIFY( m.suffix().matched == false );
+ VERIFY( m[0].first == target.begin() );
+ VERIFY( m[0].second == target.end() );
+ VERIFY( m[0].matched == true );
+}
+
+
+int
+main()
+{
+ test01();
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/extended/string_range_01_03.cc b/libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/extended/string_range_01_03.cc
new file mode 100644
index 00000000000..b50e07645ab
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/extended/string_range_01_03.cc
@@ -0,0 +1,60 @@
+// { dg-options "-std=c++0x" }
+
+//
+// 2010-06-16 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.11.2 regex_match
+// Tests ERE against a std::string target, exercising range {1,3}
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::regex re("a{1,3}", std::regex::extended);
+ std::string target("aa");
+ std::smatch m;
+
+ VERIFY( std::regex_match(target, m, re) );
+
+ VERIFY( m.size() == re.mark_count()+1 );
+ VERIFY( m.empty() == false );
+ VERIFY( m.prefix().first == target.begin() );
+ VERIFY( m.prefix().second == target.begin() );
+ VERIFY( m.prefix().matched == false );
+ VERIFY( m.suffix().first == target.end() );
+ VERIFY( m.suffix().second == target.end() );
+ VERIFY( m.suffix().matched == false );
+ VERIFY( m[0].first == target.begin() );
+ VERIFY( m[0].second == target.end() );
+ VERIFY( m[0].matched == true );
+}
+
+
+int
+main()
+{
+ test01();
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/extended/string_range_02_03.cc b/libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/extended/string_range_02_03.cc
new file mode 100644
index 00000000000..ca322a8d4cd
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/11_algorithms/02_match/extended/string_range_02_03.cc
@@ -0,0 +1,61 @@
+// { dg-options "-std=c++0x" }
+// { dg-do run { xfail *-*-* } }
+
+//
+// 2010-06-16 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.11.2 regex_match
+// Tests ERE against a std::string target, exercising range {2,3}
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::regex re("a{2,3}", std::regex::extended);
+ std::string target("aa");
+ std::smatch m;
+
+ VERIFY( std::regex_match(target, m, re) );
+
+ VERIFY( m.size() == re.mark_count()+1 );
+ VERIFY( m.empty() == false );
+ VERIFY( m.prefix().first == target.begin() );
+ VERIFY( m.prefix().second == target.begin() );
+ VERIFY( m.prefix().matched == false );
+ VERIFY( m.suffix().first == target.end() );
+ VERIFY( m.suffix().second == target.end() );
+ VERIFY( m.suffix().matched == false );
+ VERIFY( m[0].first == target.begin() );
+ VERIFY( m[0].second == target.end() );
+ VERIFY( m[0].matched == true );
+}
+
+
+int
+main()
+{
+ test01();
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/28_regex/12_iterators/regex_iterator/ctors/char/default.cc b/libstdc++-v3/testsuite/28_regex/12_iterators/regex_iterator/ctors/char/default.cc
new file mode 100644
index 00000000000..2de4a0d09b8
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/12_iterators/regex_iterator/ctors/char/default.cc
@@ -0,0 +1,35 @@
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+//
+// 2010-06-10 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.12.1 Class template regex_iterator
+
+#include <regex>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ std::regex_iterator<char*> it;
+ std::cregex_iterator cit;
+ std::sregex_iterator sit;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/12_iterators/regex_iterator/ctors/wchar_t/default.cc b/libstdc++-v3/testsuite/28_regex/12_iterators/regex_iterator/ctors/wchar_t/default.cc
new file mode 100644
index 00000000000..33fb5baa808
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/12_iterators/regex_iterator/ctors/wchar_t/default.cc
@@ -0,0 +1,35 @@
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+//
+// 2010-06-10 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.12.1 Class template regex_iterator
+
+#include <regex>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ std::regex_iterator<wchar_t*> it;
+ std::wcregex_iterator cit;
+ std::wsregex_iterator sit;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/12_iterators/regex_iterator/typedefs.cc b/libstdc++-v3/testsuite/28_regex/12_iterators/regex_iterator/typedefs.cc
new file mode 100644
index 00000000000..8ad88995078
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/12_iterators/regex_iterator/typedefs.cc
@@ -0,0 +1,40 @@
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+//
+// 2010-06-10 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.12.1 Class template regex_iterator
+
+#include <regex>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::regex_iterator<char*> it;
+
+ typedef it::regex_type regex_type;
+ typedef it::value_type value_type;
+ typedef it::difference_type difference_type;
+ typedef it::pointer pointer;
+ typedef it::reference reference;
+ typedef it::iterator_category iterator_category;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/12_iterators/regex_token_iterator/ctors/char/default.cc b/libstdc++-v3/testsuite/28_regex/12_iterators/regex_token_iterator/ctors/char/default.cc
new file mode 100644
index 00000000000..5105c7d8732
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/12_iterators/regex_token_iterator/ctors/char/default.cc
@@ -0,0 +1,35 @@
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+//
+// 2010-06-10 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.12.2 Class template regex_token_iterator
+
+#include <regex>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ std::regex_token_iterator<char*> it;
+ std::cregex_token_iterator cit;
+ std::sregex_token_iterator sit;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/12_iterators/regex_token_iterator/ctors/wchar_t/default.cc b/libstdc++-v3/testsuite/28_regex/12_iterators/regex_token_iterator/ctors/wchar_t/default.cc
new file mode 100644
index 00000000000..fe918c80d71
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/12_iterators/regex_token_iterator/ctors/wchar_t/default.cc
@@ -0,0 +1,35 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+//
+// 2010-06-10 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.12.2 Class template regex_token_iterator
+
+#include <regex>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ std::regex_token_iterator<wchar_t*> it;
+ std::wcregex_token_iterator cit;
+ std::wsregex_token_iterator sit;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/12_iterators/regex_token_iterator/typedefs.cc b/libstdc++-v3/testsuite/28_regex/12_iterators/regex_token_iterator/typedefs.cc
new file mode 100644
index 00000000000..d765ab2f403
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/12_iterators/regex_token_iterator/typedefs.cc
@@ -0,0 +1,40 @@
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+//
+// 2010-06-10 Stephen M. Webb <stephen.webb@bregmasoft.ca>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.12.2 Class template regex_token_iterator
+
+#include <regex>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::regex_token_iterator<char*> it;
+
+ typedef it::regex_type regex_type;
+ typedef it::value_type value_type;
+ typedef it::difference_type difference_type;
+ typedef it::pointer pointer;
+ typedef it::reference reference;
+ typedef it::iterator_category iterator_category;
+}