[PATCH] D22698: [libcxx] Missing member types 'traits_type' and 'string_type' in class basic_regex

Jason Liu via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 22 13:59:43 PDT 2016


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;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22698.65141.patch
Type: text/x-patch
Size: 2583 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160722/6ab44273/attachment-0001.bin>


More information about the cfe-commits mailing list