From ae1f72671e1a248730a3b73bae7ae0ee288fb57f Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 13 Mar 2021 04:50:01 +0200 Subject: [PATCH] Add test for types supported by boost::hash, but not by std::hash --- test/variant_hash.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/test/variant_hash.cpp b/test/variant_hash.cpp index ecff656..5233132 100644 --- a/test/variant_hash.cpp +++ b/test/variant_hash.cpp @@ -12,6 +12,7 @@ #include #include #include +#include using namespace boost::variant2; @@ -47,7 +48,17 @@ template class Hash, class T> void test2() BOOST_TEST_NE( h2, h3 ); } -struct X {}; +struct X +{ + int m = 0; +}; + +std::size_t hash_value( X const& x ) +{ + return boost::hash()( x.m ); +} + +struct Y {}; // no hash support int main() { @@ -57,6 +68,8 @@ int main() test(); test(); + test>(); + test2(); test2(); @@ -65,7 +78,7 @@ int main() #if !BOOST_WORKAROUND(BOOST_MSVC, < 1910) && ( !defined(_LIBCPP_STD_VER) || _LIBCPP_STD_VER > 11 ) - BOOST_TEST_TRAIT_FALSE(( detail::is_hash_enabled )); + BOOST_TEST_TRAIT_FALSE(( detail::is_hash_enabled )); #endif