diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2017-11-21 20:47:09 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2017-11-21 20:47:09 +0000 |
commit | 866e4d3853ccc0bc61e3764911d2a0f69c281f0c (patch) | |
tree | a5b1601ca999eb5b5adc347e7dbc787e7e89b78f /libstdc++-v3/include/bits/hashtable.h | |
parent | 6a33d0ff21e941fc3a65f23a753cc318aaae82b5 (diff) | |
download | gcc-866e4d3853ccc0bc61e3764911d2a0f69c281f0c.tar.gz |
PR libstdc++/48101 improve errors for invalid container specializations
PR libstdc++/48101
* include/bits/allocator.h (allocator<const _Tp>)
(allocator<volatile _Tp>, allocator<const volatile _Tp>): Add partial
specializations.
* include/bits/forward_list.h (forward_list): Add static assertions.
* include/bits/hashtable.h (__cache_default): Use
__is_nothrow_invocable instead of __is_noexcept_hash.
(_Hashtable): Add static assertions.
* include/bits/hashtable_policy.h (__is_noexcept_hash): Remove.
* include/bits/stl_deque.h (deque): Add static assertions.
* include/bits/stl_function.h (_Identity<const _Tp>): Add partial
specialization.
* include/bits/stl_list.h (list): Add static assertions.
* include/bits/stl_map.h (map): Likewise.
* include/bits/stl_multimap.h (multimap): Likewise.
* include/bits/stl_multiset.h (multiset): Likewise.
* include/bits/stl_set.h (set): Likewise.
* include/bits/stl_tree.h (_Rb_tree): Likewise.
* include/bits/stl_vector.h (vector): Likewise.
* include/bits/unordered_map.h (unordered_map, unordered_multimap):
Use typename instead of class in template-parameter-list and remove
spaces.
* include/bits/unordered_set.h (unordered_set, unordered_multiset):
Likewise.
* testsuite/23_containers/deque/48101-2_neg.cc: New test.
* testsuite/23_containers/deque/48101_neg.cc: New test.
* testsuite/23_containers/forward_list/48101-2_neg.cc: New test.
* testsuite/23_containers/forward_list/48101_neg.cc: New test.
* testsuite/23_containers/list/48101-2_neg.cc: New test.
* testsuite/23_containers/list/48101_neg.cc: New test.
* testsuite/23_containers/map/48101-2_neg.cc: New test.
* testsuite/23_containers/map/48101_neg.cc: New test.
* testsuite/23_containers/map/operations/31440.cc: Fix comparison
object to have const-qualified call operator.
* testsuite/23_containers/multimap/48101-2_neg.cc: New test.
* testsuite/23_containers/multimap/48101_neg.cc: New test.
* testsuite/23_containers/multiset/48101-2_neg.cc: New test.
* testsuite/23_containers/multiset/48101_neg.cc: New test.
* testsuite/23_containers/set/48101-2_neg.cc: New test.
* testsuite/23_containers/set/48101_neg.cc: New test.
* testsuite/23_containers/unordered_map/48101-2_neg.cc: New test.
* testsuite/23_containers/unordered_map/48101_neg.cc: New test.
* testsuite/23_containers/unordered_multimap/48101-2_neg.cc: New test.
* testsuite/23_containers/unordered_multimap/48101_neg.cc: New test.
* testsuite/23_containers/unordered_multiset/48101-2_neg.cc: New test.
* testsuite/23_containers/unordered_multiset/48101_neg.cc: New test.
* testsuite/23_containers/unordered_set/48101-2_neg.cc: New test.
* testsuite/23_containers/unordered_set/48101_neg.cc: New test.
* testsuite/23_containers/unordered_set/instantiation_neg.cc: Adjust
dg-error line number.
* testsuite/23_containers/vector/48101-2_neg.cc: New test.
* testsuite/23_containers/vector/48101_neg.cc: New test.
From-SVN: r255035
Diffstat (limited to 'libstdc++-v3/include/bits/hashtable.h')
-rw-r--r-- | libstdc++-v3/include/bits/hashtable.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/libstdc++-v3/include/bits/hashtable.h b/libstdc++-v3/include/bits/hashtable.h index e0806dc93a1..a9473c16bde 100644 --- a/libstdc++-v3/include/bits/hashtable.h +++ b/libstdc++-v3/include/bits/hashtable.h @@ -46,7 +46,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION = __not_<__and_<// Do not cache for fast hasher. __is_fast_hash<_Hash>, // Mandatory to have erase not throwing. - __detail::__is_noexcept_hash<_Tp, _Hash>>>; + __is_nothrow_invocable<const _Hash&, const _Tp&>>>; /** * Primary class template _Hashtable. @@ -186,6 +186,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __detail::_Hash_node<_Value, _Traits::__hash_cached::value>>> { + static_assert(is_same<typename remove_cv<_Value>::type, _Value>::value, + "unordered container must have a non-const, non-volatile value_type"); +#ifdef __STRICT_ANSI__ + static_assert(is_same<typename _Alloc::value_type, _Value>{}, + "unordered container must have the same value_type as its allocator"); +#endif + static_assert(__is_invocable<const _H1&, const _Key&>{}, + "hash function must be invocable with an argument of key type"); + static_assert(__is_invocable<const _Equal&, const _Key&, const _Key&>{}, + "key equality predicate must be invocable with two arguments of " + "key type"); + using __traits_type = _Traits; using __hash_cached = typename __traits_type::__hash_cached; using __node_type = __detail::_Hash_node<_Value, __hash_cached::value>; |