[libcxx] basic_regex: add traits_type, string_type

Summary:
In the synopsis in C++11 subclause 28.8 [re.regex], `basic_regex` is
specified to have member typedefs `traits_type` and `string_type`. This
change adds them to libc++.

Reviewers: mclow.lists, rsmith, hubert.reinterpretcast

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D22698

Patch by Jason Liu!


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@277526 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Hubert Tong 2016-08-02 21:34:48 +00:00
parent 4e1f9a0100
commit b49c67fad2
2 changed files with 10 additions and 0 deletions

View File

@ -127,6 +127,8 @@ class basic_regex
public: public:
// types: // types:
typedef charT value_type; typedef charT value_type;
typedef traits traits_type;
typedef typename traits::string_type string_type;
typedef regex_constants::syntax_option_type flag_type; typedef regex_constants::syntax_option_type flag_type;
typedef typename traits::locale_type locale_type; typedef typename traits::locale_type locale_type;
@ -2475,6 +2477,8 @@ class _LIBCPP_TYPE_VIS_ONLY basic_regex
public: public:
// types: // types:
typedef _CharT value_type; typedef _CharT value_type;
typedef _Traits traits_type;
typedef typename _Traits::string_type string_type;
typedef regex_constants::syntax_option_type flag_type; typedef regex_constants::syntax_option_type flag_type;
typedef typename _Traits::locale_type locale_type; typedef typename _Traits::locale_type locale_type;

View File

@ -15,6 +15,8 @@
// public: // public:
// // types: // // types:
// typedef charT value_type; // typedef charT value_type;
// typedef traits traits_type;
// typedef typename traits::string_type string_type;
// typedef regex_constants::syntax_option_type flag_type; // typedef regex_constants::syntax_option_type flag_type;
// typedef typename traits::locale_type locale_type; // typedef typename traits::locale_type locale_type;
@ -25,11 +27,15 @@
int main() int main()
{ {
static_assert((std::is_same<std::basic_regex<char>::value_type, char>::value), ""); 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, static_assert((std::is_same<std::basic_regex<char>::flag_type,
std::regex_constants::syntax_option_type>::value), ""); 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<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>::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, static_assert((std::is_same<std::basic_regex<wchar_t>::flag_type,
std::regex_constants::syntax_option_type>::value), ""); std::regex_constants::syntax_option_type>::value), "");
static_assert((std::is_same<std::basic_regex<wchar_t>::locale_type, std::locale>::value), ""); static_assert((std::is_same<std::basic_regex<wchar_t>::locale_type, std::locale>::value), "");