// Copyright 2020 Peter Dimov. // Distributed under the Boost Software License, Version 1.0. // http://www.boost.org/LICENSE_1_0.txt #if defined(_MSC_VER) # pragma warning( disable: 4244 ) // conversion from int to float, possible loss of data #endif #include #include #include #include #include using namespace boost::variant2; template class Hash, class T1, class T2, class T3> void test() { variant v1( in_place_index_t<0>{} ); std::size_t h1 = Hash()( v1 ); variant v2( in_place_index_t<1>{} ); std::size_t h2 = Hash()( v2 ); variant v3( in_place_index_t<2>{} ); std::size_t h3 = Hash()( v3 ); BOOST_TEST_NE( h1, h2 ); BOOST_TEST_NE( h1, h3 ); BOOST_TEST_NE( h2, h3 ); } template class Hash, class T> void test2() { variant v1( 0 ); std::size_t h1 = Hash()( v1 ); variant v2( 1 ); std::size_t h2 = Hash()( v2 ); variant v3( 2 ); std::size_t h3 = Hash()( v3 ); BOOST_TEST_NE( h1, h2 ); BOOST_TEST_NE( h1, h3 ); BOOST_TEST_NE( h2, h3 ); } struct X {}; int main() { test(); test(); test(); test(); test2(); test2(); test2(); test2(); #if !BOOST_WORKAROUND(BOOST_MSVC, < 1910) && ( !defined(_LIBCPP_STD_VER) || _LIBCPP_STD_VER > 11 ) BOOST_TEST_TRAIT_FALSE(( detail::is_hash_enabled )); #endif return boost::report_errors(); }