summaryrefslogtreecommitdiffstats
path: root/libcxx/include/variant
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2017-01-21 00:02:12 +0000
committerEric Fiselier <eric@efcs.ca>2017-01-21 00:02:12 +0000
commitf9127593a9fd0ef585fed52f838d89c825b8cd72 (patch)
tree62a21ebb1691065d901bb9bb1294b3a2bd56021f /libcxx/include/variant
parent59e1df524f41d3c2ba1de62f4abea1582cc7332e (diff)
downloadbcm5719-llvm-f9127593a9fd0ef585fed52f838d89c825b8cd72.tar.gz
bcm5719-llvm-f9127593a9fd0ef585fed52f838d89c825b8cd72.zip
Implement P0513R0 - "Poisoning the Hash"
Summary: Exactly what the title says. This patch also adds a `std::hash<nullptr_t>` specialization in C++17, but it was not added by this paper and I can't find the actual paper that adds it. See http://wg21.link/P0513R0 for more info. If there are no comments in the next couple of days I'll commit this Reviewers: mclow.lists, K-ballo, EricWF Reviewed By: EricWF Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D28938 llvm-svn: 292684
Diffstat (limited to 'libcxx/include/variant')
-rw-r--r--libcxx/include/variant6
1 files changed, 4 insertions, 2 deletions
diff --git a/libcxx/include/variant b/libcxx/include/variant
index 4396f1062f5..67d4e3c9992 100644
--- a/libcxx/include/variant
+++ b/libcxx/include/variant
@@ -1534,7 +1534,8 @@ auto swap(variant<_Types...>& __lhs,
}
template <class... _Types>
-struct _LIBCPP_TEMPLATE_VIS hash<variant<_Types...>> {
+struct _LIBCPP_TEMPLATE_VIS hash<
+ __enable_hash_helper<variant<_Types...>, remove_const_t<_Types>...>> {
using argument_type = variant<_Types...>;
using result_type = size_t;
@@ -1547,7 +1548,8 @@ struct _LIBCPP_TEMPLATE_VIS hash<variant<_Types...>> {
: __variant::__visit_alt(
[](const auto& __alt) {
using __alt_type = decay_t<decltype(__alt)>;
- using __value_type = typename __alt_type::__value_type;
+ using __value_type = remove_const_t<
+ typename __alt_type::__value_type>;
return hash<__value_type>{}(__alt.__value);
},
__v);
OpenPOWER on IntegriCloud