Add static_assert to set/multiset/map/multimap/forward_list/deque that the allocator's value_type match the container's value_type. vector/unordered/list/string already do this. Add tests for all the containers to verify this.
llvm-svn: 254119
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 94f89aeec5eb6a720f734b84523451d92206c0bb
diff --git a/include/deque b/include/deque
index b0b778a..c6fbd51 100644
--- a/include/deque
+++ b/include/deque
@@ -1196,6 +1196,9 @@
typedef _Tp value_type;
typedef _Allocator allocator_type;
+ static_assert((is_same<typename allocator_type::value_type, value_type>::value),
+ "Allocator::value_type must be same type as value_type");
+
typedef __deque_base<value_type, allocator_type> __base;
typedef typename __base::__alloc_traits __alloc_traits;
diff --git a/include/forward_list b/include/forward_list
index 8a87fc5..adbc32c 100644
--- a/include/forward_list
+++ b/include/forward_list
@@ -537,6 +537,9 @@
typedef _Tp value_type;
typedef _Alloc allocator_type;
+ static_assert((is_same<typename allocator_type::value_type, value_type>::value),
+ "Allocator::value_type must be same type as value_type");
+
typedef value_type& reference;
typedef const value_type& const_reference;
typedef typename allocator_traits<allocator_type>::pointer pointer;
diff --git a/include/map b/include/map
index 561c3dd..adfb4cd 100644
--- a/include/map
+++ b/include/map
@@ -840,6 +840,9 @@
typedef value_type& reference;
typedef const value_type& const_reference;
+ static_assert((is_same<typename allocator_type::value_type, value_type>::value),
+ "Allocator::value_type must be same type as value_type");
+
class _LIBCPP_TYPE_VIS_ONLY value_compare
: public binary_function<value_type, value_type, bool>
{
@@ -1696,6 +1699,9 @@
typedef value_type& reference;
typedef const value_type& const_reference;
+ static_assert((is_same<typename allocator_type::value_type, value_type>::value),
+ "Allocator::value_type must be same type as value_type");
+
class _LIBCPP_TYPE_VIS_ONLY value_compare
: public binary_function<value_type, value_type, bool>
{
diff --git a/include/set b/include/set
index 9d64a52..ac69e08 100644
--- a/include/set
+++ b/include/set
@@ -409,6 +409,9 @@
typedef value_type& reference;
typedef const value_type& const_reference;
+ static_assert((is_same<typename allocator_type::value_type, value_type>::value),
+ "Allocator::value_type must be same type as value_type");
+
private:
typedef __tree<value_type, value_compare, allocator_type> __base;
typedef allocator_traits<allocator_type> __alloc_traits;
@@ -819,6 +822,9 @@
typedef value_type& reference;
typedef const value_type& const_reference;
+ static_assert((is_same<typename allocator_type::value_type, value_type>::value),
+ "Allocator::value_type must be same type as value_type");
+
private:
typedef __tree<value_type, value_compare, allocator_type> __base;
typedef allocator_traits<allocator_type> __alloc_traits;