summaryrefslogtreecommitdiffstats
path: root/libcxx/include/variant
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2016-12-02 23:38:31 +0000
committerEric Fiselier <eric@efcs.ca>2016-12-02 23:38:31 +0000
commit918f32fc7b2f4e3c7f3b76db941822aa8ffb5197 (patch)
tree88dcb41c643f7fdb33f33ee1051e1278ef8f4ea8 /libcxx/include/variant
parent75453b057b6b76889ff3a5bca99f8099c628b389 (diff)
downloadbcm5719-llvm-918f32fc7b2f4e3c7f3b76db941822aa8ffb5197.tar.gz
bcm5719-llvm-918f32fc7b2f4e3c7f3b76db941822aa8ffb5197.zip
Make variant's index part of the hash value
llvm-svn: 288554
Diffstat (limited to 'libcxx/include/variant')
-rw-r--r--libcxx/include/variant4
1 files changed, 3 insertions, 1 deletions
diff --git a/libcxx/include/variant b/libcxx/include/variant
index 1207b591b8e..45efc78ed19 100644
--- a/libcxx/include/variant
+++ b/libcxx/include/variant
@@ -1526,7 +1526,8 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<variant<_Types...>> {
inline _LIBCPP_INLINE_VISIBILITY
result_type operator()(const argument_type& __v) const {
using __variant_detail::__visitation::__variant;
- return __v.valueless_by_exception()
+ size_t __res =
+ __v.valueless_by_exception()
? __v.index()
: __variant::__visit_alt(
[](const auto& __alt) {
@@ -1535,6 +1536,7 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<variant<_Types...>> {
return hash<__value_type>{}(__alt.__value);
},
__v);
+ return __hash_combine(__res, hash<size_t>{}(__v.index()));
}
};
OpenPOWER on IntegriCloud