Files
boost_unordered/test/unordered/hash_is_avalanching_test.cpp
T

76 lines
1.5 KiB
C++
Raw Normal View History

2022-10-30 12:58:57 +02:00
// Copyright 2022 Peter Dimov
2024-05-29 19:51:32 +02:00
// Copyright 2024 Joaquin M Lopez Munoz
2022-10-30 12:58:57 +02:00
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
2022-10-31 13:27:09 +02:00
// an imitation of a third-party header specializing hash_is_avalanching
// (boost/container_hash/hash.hpp is an example doing that)
#include <boost/type_traits/integral_constant.hpp>
struct X3
{
};
namespace boost
{
namespace unordered
{
template<class T> struct hash_is_avalanching;
template<> struct hash_is_avalanching< ::X3 >: boost::true_type {};
} // namespace unordered
} // namespace boost
//
2022-10-30 12:58:57 +02:00
#include <boost/unordered/hash_traits.hpp>
#include <boost/core/lightweight_test_trait.hpp>
2024-05-29 19:51:32 +02:00
#include <type_traits>
2022-10-30 12:58:57 +02:00
struct X1
{
};
struct X2
{
typedef void is_avalanching;
};
2024-05-29 19:51:32 +02:00
struct X4
{
using is_avalanching = std::false_type;
};
struct X5
{
using is_avalanching = std::true_type;
};
struct X6
{
using is_avalanching = boost::false_type;
};
struct X7
{
using is_avalanching = boost::true_type;
};
2022-10-30 12:58:57 +02:00
int main()
{
using boost::unordered::hash_is_avalanching;
BOOST_TEST_TRAIT_FALSE((hash_is_avalanching<X1>));
BOOST_TEST_TRAIT_TRUE((hash_is_avalanching<X2>));
2022-10-31 13:27:09 +02:00
BOOST_TEST_TRAIT_TRUE((hash_is_avalanching<X3>));
2024-05-29 19:51:32 +02:00
BOOST_TEST_TRAIT_FALSE((hash_is_avalanching<X4>));
BOOST_TEST_TRAIT_TRUE((hash_is_avalanching<X5>));
BOOST_TEST_TRAIT_FALSE((hash_is_avalanching<X6>));
BOOST_TEST_TRAIT_TRUE((hash_is_avalanching<X7>));
2022-10-30 12:58:57 +02:00
return boost::report_errors();
}