summaryrefslogtreecommitdiff
path: root/include/optional
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
commit952eaecfc6fa504c40d6f7220d8c017d014cda0c (patch)
tree91f54ab548a1a5a8c94abc48bbc864bd2ed76c7a /include/optional
parentee856f131dc433ff3c7522a4782aed7ac6de4f4a (diff)
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 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292684 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/optional')
-rw-r--r--include/optional6
1 files changed, 4 insertions, 2 deletions
diff --git a/include/optional b/include/optional
index c002cc729..b13a2d5f7 100644
--- a/include/optional
+++ b/include/optional
@@ -1295,7 +1295,9 @@ optional<_Tp> make_optional(initializer_list<_Up> __il, _Args&&... __args)
}
template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS hash<optional<_Tp> >
+struct _LIBCPP_TEMPLATE_VIS hash<
+ __enable_hash_helper<optional<_Tp>, remove_const_t<_Tp>>
+>
{
typedef optional<_Tp> argument_type;
typedef size_t result_type;
@@ -1303,7 +1305,7 @@ struct _LIBCPP_TEMPLATE_VIS hash<optional<_Tp> >
_LIBCPP_INLINE_VISIBILITY
result_type operator()(const argument_type& __opt) const _NOEXCEPT
{
- return static_cast<bool>(__opt) ? hash<_Tp>()(*__opt) : 0;
+ return static_cast<bool>(__opt) ? hash<remove_const_t<_Tp>>()(*__opt) : 0;
}
};