jasonliu created this revision.
jasonliu added reviewers: mclow.lists, rsmith, hubert.reinterpretcast.
jasonliu added a subscriber: cfe-commits.

In standard 28.8 p3, class basic_regex is supposed to have 'traits_type' and 
'string_type' as its member types. However, they are missing from the library's 
implementation. Unexpected error occurs when user have lines like 
"std::basic_regex<char>::traits_type" or "std::basic_regex<char>::string_type".

https://reviews.llvm.org/D22698

Files:
  include/regex
  test/std/re/re.regex/types.pass.cpp

Index: test/std/re/re.regex/types.pass.cpp
===================================================================
--- test/std/re/re.regex/types.pass.cpp
+++ test/std/re/re.regex/types.pass.cpp
@@ -15,6 +15,8 @@
 // public:
 //     // types:
 //     typedef charT                               value_type;
+//     typedef traits                              traits_type;
+//     typedef typename traits::string_type        string_type;
 //     typedef regex_constants::syntax_option_type flag_type;
 //     typedef typename traits::locale_type        locale_type;
 
@@ -25,11 +27,15 @@
 int main()
 {
     static_assert((std::is_same<std::basic_regex<char>::value_type, 
char>::value), "");
+    static_assert((std::is_same<std::basic_regex<char>::traits_type, 
std::regex_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_regex<char>::string_type, 
std::basic_string<char> >::value), "");
     static_assert((std::is_same<std::basic_regex<char>::flag_type,
                                 
std::regex_constants::syntax_option_type>::value), "");
     static_assert((std::is_same<std::basic_regex<char>::locale_type, 
std::locale>::value), "");
 
     static_assert((std::is_same<std::basic_regex<wchar_t>::value_type, 
wchar_t>::value), "");
+    static_assert((std::is_same<std::basic_regex<wchar_t>::traits_type, 
std::regex_traits<wchar_t> >::value), "");
+    static_assert((std::is_same<std::basic_regex<wchar_t>::string_type, 
std::basic_string<wchar_t> >::value), "");
     static_assert((std::is_same<std::basic_regex<wchar_t>::flag_type,
                                 
std::regex_constants::syntax_option_type>::value), "");
     static_assert((std::is_same<std::basic_regex<wchar_t>::locale_type, 
std::locale>::value), "");
Index: include/regex
===================================================================
--- include/regex
+++ include/regex
@@ -127,6 +127,8 @@
 public:
     // types:
     typedef charT                               value_type;
+    typedef traits                              traits_type;
+    typedef typename traits::string_type        string_type;
     typedef regex_constants::syntax_option_type flag_type;
     typedef typename traits::locale_type        locale_type;
 
@@ -2475,6 +2477,8 @@
 public:
     // types:
     typedef _CharT                              value_type;
+    typedef _Traits                             traits_type;
+    typedef typename _Traits::string_type       string_type;
     typedef regex_constants::syntax_option_type flag_type;
     typedef typename _Traits::locale_type       locale_type;
 


Index: test/std/re/re.regex/types.pass.cpp
===================================================================
--- test/std/re/re.regex/types.pass.cpp
+++ test/std/re/re.regex/types.pass.cpp
@@ -15,6 +15,8 @@
 // public:
 //     // types:
 //     typedef charT                               value_type;
+//     typedef traits                              traits_type;
+//     typedef typename traits::string_type        string_type;
 //     typedef regex_constants::syntax_option_type flag_type;
 //     typedef typename traits::locale_type        locale_type;
 
@@ -25,11 +27,15 @@
 int main()
 {
     static_assert((std::is_same<std::basic_regex<char>::value_type, char>::value), "");
+    static_assert((std::is_same<std::basic_regex<char>::traits_type, std::regex_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_regex<char>::string_type, std::basic_string<char> >::value), "");
     static_assert((std::is_same<std::basic_regex<char>::flag_type,
                                 std::regex_constants::syntax_option_type>::value), "");
     static_assert((std::is_same<std::basic_regex<char>::locale_type, std::locale>::value), "");
 
     static_assert((std::is_same<std::basic_regex<wchar_t>::value_type, wchar_t>::value), "");
+    static_assert((std::is_same<std::basic_regex<wchar_t>::traits_type, std::regex_traits<wchar_t> >::value), "");
+    static_assert((std::is_same<std::basic_regex<wchar_t>::string_type, std::basic_string<wchar_t> >::value), "");
     static_assert((std::is_same<std::basic_regex<wchar_t>::flag_type,
                                 std::regex_constants::syntax_option_type>::value), "");
     static_assert((std::is_same<std::basic_regex<wchar_t>::locale_type, std::locale>::value), "");
Index: include/regex
===================================================================
--- include/regex
+++ include/regex
@@ -127,6 +127,8 @@
 public:
     // types:
     typedef charT                               value_type;
+    typedef traits                              traits_type;
+    typedef typename traits::string_type        string_type;
     typedef regex_constants::syntax_option_type flag_type;
     typedef typename traits::locale_type        locale_type;
 
@@ -2475,6 +2477,8 @@
 public:
     // types:
     typedef _CharT                              value_type;
+    typedef _Traits                             traits_type;
+    typedef typename _Traits::string_type       string_type;
     typedef regex_constants::syntax_option_type flag_type;
     typedef typename _Traits::locale_type       locale_type;
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to