diff --git a/stl/inc/array b/stl/inc/array index 8eab5545113..f9321688f5e 100644 --- a/stl/inc/array +++ b/stl/inc/array @@ -406,6 +406,9 @@ struct pointer_traits<_Array_iterator<_Ty, _Size>> { _EXPORT_STD template class array { // fixed size array of values public: + static_assert(is_object_v<_Ty>, "The C++ Standard forbids containers of non-object types " + "because of [container.requirements]."); + using value_type = _Ty; using size_type = size_t; using difference_type = ptrdiff_t; @@ -592,6 +595,9 @@ struct _Empty_array_element {}; template class array<_Ty, 0> { public: + static_assert(is_object_v<_Ty>, "The C++ Standard forbids containers of non-object types " + "because of [container.requirements]."); + using value_type = _Ty; using size_type = size_t; using difference_type = ptrdiff_t; diff --git a/stl/inc/deque b/stl/inc/deque index 5667b19def2..1bbf465b2b9 100644 --- a/stl/inc/deque +++ b/stl/inc/deque @@ -575,6 +575,8 @@ private: friend _Tidy_guard; static_assert(!_ENFORCE_MATCHING_ALLOCATORS || is_same_v<_Ty, typename _Alloc::value_type>, _MISMATCHED_ALLOCATOR_MESSAGE("deque", "T")); + static_assert(is_object_v<_Ty>, "The C++ Standard forbids containers of non-object types " + "because of [container.requirements]."); using _Alty = _Rebind_alloc_t<_Alloc, _Ty>; using _Alty_traits = allocator_traits<_Alty>; diff --git a/stl/inc/forward_list b/stl/inc/forward_list index df9c08303fc..66aada2d043 100644 --- a/stl/inc/forward_list +++ b/stl/inc/forward_list @@ -519,6 +519,8 @@ private: static_assert(!_ENFORCE_MATCHING_ALLOCATORS || is_same_v<_Ty, typename _Alloc::value_type>, _MISMATCHED_ALLOCATOR_MESSAGE("forward_list", "T")); + static_assert(is_object_v<_Ty>, "The C++ Standard forbids containers of non-object types " + "because of [container.requirements]."); using _Scary_val = _Flist_val, _Flist_simple_types<_Ty>, _Flist_iter_types<_Ty, typename _Alty_traits::size_type, typename _Alty_traits::difference_type, diff --git a/stl/inc/list b/stl/inc/list index 3671b51be47..0df30ff122d 100644 --- a/stl/inc/list +++ b/stl/inc/list @@ -776,6 +776,8 @@ private: public: static_assert(!_ENFORCE_MATCHING_ALLOCATORS || is_same_v<_Ty, typename _Alloc::value_type>, _MISMATCHED_ALLOCATOR_MESSAGE("list", "T")); + static_assert(is_object_v<_Ty>, "The C++ Standard forbids containers of non-object types " + "because of [container.requirements]."); using value_type = _Ty; using allocator_type = _Alloc; diff --git a/stl/inc/map b/stl/inc/map index 63bbefdb827..eaca60e2932 100644 --- a/stl/inc/map +++ b/stl/inc/map @@ -75,6 +75,10 @@ class map : public _Tree<_Tmap_traits<_Kty, _Ty, _Pr, _Alloc, false>> { public: static_assert(!_ENFORCE_MATCHING_ALLOCATORS || is_same_v, typename _Alloc::value_type>, _MISMATCHED_ALLOCATOR_MESSAGE("map", "pair")); + static_assert(is_object_v<_Kty>, "The C++ Standard forbids containers of non-object types " + "because of [container.requirements]."); + static_assert(is_object_v<_Ty>, "The C++ Standard forbids containers of non-object types " + "because of [container.requirements]."); using _Mybase = _Tree<_Tmap_traits<_Kty, _Ty, _Pr, _Alloc, false>>; using _Nodeptr = typename _Mybase::_Nodeptr; @@ -457,6 +461,10 @@ class multimap : public _Tree<_Tmap_traits<_Kty, _Ty, _Pr, _Alloc, true>> { public: static_assert(!_ENFORCE_MATCHING_ALLOCATORS || is_same_v, typename _Alloc::value_type>, _MISMATCHED_ALLOCATOR_MESSAGE("multimap", "pair")); + static_assert(is_object_v<_Kty>, "The C++ Standard forbids containers of non-object types " + "because of [container.requirements]."); + static_assert(is_object_v<_Ty>, "The C++ Standard forbids containers of non-object types " + "because of [container.requirements]."); using _Mybase = _Tree<_Tmap_traits<_Kty, _Ty, _Pr, _Alloc, true>>; using key_type = _Kty; diff --git a/stl/inc/queue b/stl/inc/queue index f3b68ee2c06..68d7ec4ab1f 100644 --- a/stl/inc/queue +++ b/stl/inc/queue @@ -34,6 +34,8 @@ public: using container_type = _Container; static_assert(is_same_v<_Ty, value_type>, "container adaptors require consistent types"); + static_assert(is_object_v<_Ty>, "The C++ Standard forbids container adaptors of non-object types " + "because of [container.requirements]."); queue() = default; @@ -234,6 +236,8 @@ public: using value_compare = _Pr; static_assert(is_same_v<_Ty, value_type>, "container adaptors require consistent types"); + static_assert(is_object_v<_Ty>, "The C++ Standard forbids container adaptors of non-object types " + "because of [container.requirements]."); priority_queue() = default; diff --git a/stl/inc/set b/stl/inc/set index 666069e89fe..f0fb28b05f6 100644 --- a/stl/inc/set +++ b/stl/inc/set @@ -54,6 +54,8 @@ class set : public _Tree<_Tset_traits<_Kty, _Pr, _Alloc, false>> { public: static_assert(!_ENFORCE_MATCHING_ALLOCATORS || is_same_v<_Kty, typename _Alloc::value_type>, _MISMATCHED_ALLOCATOR_MESSAGE("set", "T")); + static_assert(is_object_v<_Kty>, "The C++ Standard forbids containers of non-object types " + "because of [container.requirements]."); using _Mybase = _Tree<_Tset_traits<_Kty, _Pr, _Alloc, false>>; using key_type = _Kty; @@ -265,6 +267,8 @@ class multiset : public _Tree<_Tset_traits<_Kty, _Pr, _Alloc, true>> { public: static_assert(!_ENFORCE_MATCHING_ALLOCATORS || is_same_v<_Kty, typename _Alloc::value_type>, _MISMATCHED_ALLOCATOR_MESSAGE("multiset", "T")); + static_assert(is_object_v<_Kty>, "The C++ Standard forbids containers of non-object types " + "because of [container.requirements]."); using _Mybase = _Tree<_Tset_traits<_Kty, _Pr, _Alloc, true>>; using key_type = _Kty; diff --git a/stl/inc/stack b/stl/inc/stack index 6e8a178ac74..d23c4305a56 100644 --- a/stl/inc/stack +++ b/stl/inc/stack @@ -32,6 +32,8 @@ public: using container_type = _Container; static_assert(is_same_v<_Ty, value_type>, "container adaptors require consistent types"); + static_assert(is_object_v<_Ty>, "The C++ Standard forbids container adaptors of non-object types " + "because of [container.requirements]."); stack() = default; diff --git a/stl/inc/unordered_map b/stl/inc/unordered_map index dfc37c0068d..40561f6eb79 100644 --- a/stl/inc/unordered_map +++ b/stl/inc/unordered_map @@ -69,6 +69,10 @@ class unordered_map : public _Hash<_Umap_traits<_Kty, _Ty, _Uhash_compare<_Kty, public: static_assert(!_ENFORCE_MATCHING_ALLOCATORS || is_same_v, typename _Alloc::value_type>, _MISMATCHED_ALLOCATOR_MESSAGE("unordered_map", "pair")); + static_assert(is_object_v<_Kty>, "The C++ Standard forbids containers of non-object types " + "because of [container.requirements]."); + static_assert(is_object_v<_Ty>, "The C++ Standard forbids containers of non-object types " + "because of [container.requirements]."); private: using _Mytraits = _Uhash_compare<_Kty, _Hasher, _Keyeq>; @@ -557,6 +561,10 @@ public: static_assert(!_ENFORCE_MATCHING_ALLOCATORS || is_same_v, typename _Alloc::value_type>, _MISMATCHED_ALLOCATOR_MESSAGE( "unordered_multimap", "pair")); + static_assert(is_object_v<_Kty>, "The C++ Standard forbids containers of non-object types " + "because of [container.requirements]."); + static_assert(is_object_v<_Ty>, "The C++ Standard forbids containers of non-object types " + "because of [container.requirements]."); private: using _Mytraits = _Uhash_compare<_Kty, _Hasher, _Keyeq>; diff --git a/stl/inc/unordered_set b/stl/inc/unordered_set index 02ffe73f50a..0401a5a4628 100644 --- a/stl/inc/unordered_set +++ b/stl/inc/unordered_set @@ -66,6 +66,8 @@ class unordered_set : public _Hash<_Uset_traits<_Kty, _Uhash_compare<_Kty, _Hash public: static_assert(!_ENFORCE_MATCHING_ALLOCATORS || is_same_v<_Kty, typename _Alloc::value_type>, _MISMATCHED_ALLOCATOR_MESSAGE("unordered_set", "T")); + static_assert(is_object_v<_Kty>, "The C++ Standard forbids containers of non-object types " + "because of [container.requirements]."); private: using _Mytraits = _Uhash_compare<_Kty, _Hasher, _Keyeq>; @@ -411,6 +413,8 @@ class unordered_multiset : public _Hash<_Uset_traits<_Kty, _Uhash_compare<_Kty, public: static_assert(!_ENFORCE_MATCHING_ALLOCATORS || is_same_v<_Kty, typename _Alloc::value_type>, _MISMATCHED_ALLOCATOR_MESSAGE("unordered_multiset", "T")); + static_assert(is_object_v<_Kty>, "The C++ Standard forbids containers of non-object types " + "because of [container.requirements]."); private: using _Mytraits = _Uhash_compare<_Kty, _Hasher, _Keyeq>; diff --git a/stl/inc/vector b/stl/inc/vector index dee6fb99578..1d8ec8a59d6 100644 --- a/stl/inc/vector +++ b/stl/inc/vector @@ -447,6 +447,8 @@ private: public: static_assert(!_ENFORCE_MATCHING_ALLOCATORS || is_same_v<_Ty, typename _Alloc::value_type>, _MISMATCHED_ALLOCATOR_MESSAGE("vector", "T")); + static_assert(is_object_v<_Ty>, "The C++ Standard forbids containers of non-object types " + "because of [container.requirements]."); using value_type = _Ty; using allocator_type = _Alloc; diff --git a/stl/inc/xmemory b/stl/inc/xmemory index 6f2a28fb780..7a0597f0941 100644 --- a/stl/inc/xmemory +++ b/stl/inc/xmemory @@ -907,6 +907,10 @@ class allocator { public: static_assert(!is_const_v<_Ty>, "The C++ Standard forbids containers of const elements " "because allocator is ill-formed."); + static_assert(!is_function_v<_Ty>, "The C++ Standard forbids allocators for function elements " + "because of [allocator.requirements]."); + static_assert(!is_reference_v<_Ty>, "The C++ Standard forbids allocators for reference elements " + "because of [allocator.requirements]."); using _From_primary = allocator;