// { dg-options "-Wdeprecated" } // { dg-do compile { target c++17 } } #include struct S { }; // std::hash is a disabled specialization. // Test std::hash size template constexpr std::size_t hash_size = sizeof(std::hash>); #if _GLIBCXX_INLINE_VERSION // For the unstable ABI the size should always be one. template constexpr bool check_hash_size = hash_size == 1; #else // For the default ABI, the std::hash specialization has sizeof...(Ts) // base classes of types __hash_empty_base>... and if // the same type occurs more than once they must have unique addresses. template constexpr bool check_hash_size = hash_size == Size; #endif static_assert( check_hash_size<1, int> ); static_assert( check_hash_size<1, int, long, double> ); static_assert( check_hash_size<2, int, long, int> ); static_assert( check_hash_size<2, int, long, const int> ); static_assert( check_hash_size<3, int, int, const int> ); static_assert( check_hash_size<1, S> ); static_assert( check_hash_size<1, int, S> ); static_assert( check_hash_size<2, int, S, int> ); static_assert( check_hash_size<2, int, S, int, S> ); static_assert( check_hash_size<2, int, S, S, int> ); static_assert( check_hash_size<3, int, S, S, int, S> ); // For the default ABI this has two __hash_empty_base base classes, // for the unstable ABI it does not. struct H : std::hash>, std::hash> { }; static_assert( sizeof(H) == hash_size ); // Likewise, even though one of the base classes is a disabled specialization. struct HX : std::hash>, std::hash> { }; static_assert( sizeof(HX) == hash_size );