| 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 | |
| 19 | BOOST_PRAGMA_MESSAGE( "Skipping test because BOOST_NO_CXX11_HDR_TUPLE is defined") |
| 20 | int main() {} |
| 21 | |
| 22 | #elif !defined(BOOST_DESCRIBE_CXX14) |
| 23 | |
| 24 | BOOST_PRAGMA_MESSAGE( "Skipping test because BOOST_DESCRIBE_CXX14 is not defined") |
| 25 | int main() {} |
| 26 | |
| 27 | #else |
| 28 | |
| 29 | namespace user |
| 30 | { |
| 31 | |
| 32 | struct Y3 |
| 33 | { |
| 34 | int a; |
| 35 | int b; |
| 36 | }; |
| 37 | |
| 38 | BOOST_DESCRIBE_STRUCT(Y3, (), (a, b)) |
| 39 | |
| 40 | } // namespace user |
| 41 | |
| 42 | namespace std |
| 43 | { |
| 44 | |
| 45 | template<> struct tuple_size<user::Y3>: std::integral_constant<std::size_t, 2> |
| 46 | { |
| 47 | }; |
| 48 | |
| 49 | } // namespace std |
| 50 | |
| 51 | namespace boost |
| 52 | { |
| 53 | namespace container_hash |
| 54 | { |
| 55 | |
| 56 | template<> struct is_tuple_like<user::Y3>: boost::false_type {}; |
| 57 | |
| 58 | } // namespace container_hash |
| 59 | } // namespace boost |
| 60 | |
| 61 | template<class T> std::size_t hv( T const& t ) |
| 62 | { |
| 63 | return boost::hash<T>()( t ); |
| 64 | } |
| 65 | |
| 66 | int 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 |
