summaryrefslogtreecommitdiffstats
path: root/libcxx/include
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2017-03-15 18:41:11 +0000
committerMarshall Clow <mclow.lists@gmail.com>2017-03-15 18:41:11 +0000
commit4069c2bc483b31ba78075a42d939d97d9256e2fb (patch)
treec68af235b5b367ac080109c813d22faf2a71714b /libcxx/include
parent0d98b03b9f61ba35d24a590c8b4950e69b57a683 (diff)
downloadbcm5719-llvm-4069c2bc483b31ba78075a42d939d97d9256e2fb.tar.gz
bcm5719-llvm-4069c2bc483b31ba78075a42d939d97d9256e2fb.zip
Implement LWG#2761: 'basic_string should require that charT match traits::char_type'. Tests for string_view, too
llvm-svn: 297872
Diffstat (limited to 'libcxx/include')
-rw-r--r--libcxx/include/string4
-rw-r--r--libcxx/include/string_view4
2 files changed, 6 insertions, 2 deletions
diff --git a/libcxx/include/string b/libcxx/include/string
index e1c64faf9e1..714ff84dcb9 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -637,7 +637,7 @@ public:
typedef basic_string __self;
typedef basic_string_view<_CharT, _Traits> __self_view;
typedef _Traits traits_type;
- typedef typename traits_type::char_type value_type;
+ typedef _CharT value_type;
typedef _Allocator allocator_type;
typedef allocator_traits<allocator_type> __alloc_traits;
typedef typename __alloc_traits::size_type size_type;
@@ -648,7 +648,7 @@ public:
typedef typename __alloc_traits::const_pointer const_pointer;
static_assert(is_pod<value_type>::value, "Character type of basic_string must be a POD");
- static_assert((is_same<_CharT, value_type>::value),
+ static_assert((is_same<_CharT, typename traits_type::char_type>::value),
"traits_type::char_type must be the same type as CharT");
static_assert((is_same<typename allocator_type::value_type, value_type>::value),
"Allocator::value_type must be same type as value_type");
diff --git a/libcxx/include/string_view b/libcxx/include/string_view
index 8be61328e8d..5c42b36ca56 100644
--- a/libcxx/include/string_view
+++ b/libcxx/include/string_view
@@ -199,6 +199,10 @@ public:
typedef ptrdiff_t difference_type;
static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1);
+ static_assert(is_pod<value_type>::value, "Character type of basic_string_view must be a POD");
+ static_assert((is_same<_CharT, typename traits_type::char_type>::value),
+ "traits_type::char_type must be the same type as CharT");
+
// [string.view.cons], construct/copy
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
basic_string_view() _NOEXCEPT : __data (nullptr), __size(0) {}
OpenPOWER on IntegriCloud