1// Copyright 2022 Peter Dimov.
2// Distributed under the Boost Software License, Version 1.0.
3// https://www.boost.org/LICENSE_1_0.txt
4
5#if defined(__clang__)
6# pragma clang diagnostic ignored "-Wmismatched-tags"
7#endif
8
9#include <boost/container_hash/hash.hpp>
10#include <boost/core/lightweight_test.hpp>
11#include <boost/type_traits/integral_constant.hpp>
12#include <boost/describe/class.hpp>
13#include <boost/config.hpp>
14#include <boost/config/pragma_message.hpp>
15#include <utility>
16
17#if defined(BOOST_NO_CXX11_HDR_TUPLE)
18
19BOOST_PRAGMA_MESSAGE( "Skipping test because BOOST_NO_CXX11_HDR_TUPLE is defined" )
20int main() {}
21
22#elif !defined(BOOST_DESCRIBE_CXX14)
23
24BOOST_PRAGMA_MESSAGE( "Skipping test because BOOST_DESCRIBE_CXX14 is not defined" )
25int main() {}
26
27#else
28
29namespace user
30{
31
32struct Y3
33{
34 int a;
35 int b;
36};
37
38BOOST_DESCRIBE_STRUCT(Y3, (), (a, b))
39
40} // namespace user
41
42namespace std
43{
44
45template<> struct tuple_size<user::Y3>: std::integral_constant<std::size_t, 2>
46{
47};
48
49} // namespace std
50
51namespace boost
52{
53namespace container_hash
54{
55
56 template<> struct is_tuple_like<user::Y3>: boost::false_type {};
57
58} // namespace container_hash
59} // namespace boost
60
61template<class T> std::size_t hv( T const& t )
62{
63 return boost::hash<T>()( t );
64}
65
66int main()
67{
68 {
69 user::Y3 tp = { .a: 1, .b: 2 };
70 int const a[] = { 1, 2 };
71
72 BOOST_TEST_EQ( hv(tp), hv(a) );
73 }
74
75 return boost::report_errors();
76}
77
78#endif
79

source code of boost/libs/container_hash/test/hash_tuple_like_test2.cpp