forked from boostorg/unordered
updated is_avalanching trait protocol
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/* Hash function characterization.
|
||||
*
|
||||
* Copyright 2022 Joaquin M Lopez Munoz.
|
||||
* Copyright 2022-2024 Joaquin M Lopez Munoz.
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -19,12 +19,28 @@ namespace unordered{
|
||||
namespace detail{
|
||||
|
||||
template<typename Hash,typename=void>
|
||||
struct hash_is_avalanching_impl: std::false_type{};
|
||||
struct hash_is_avalanching_impl:std::false_type{};
|
||||
|
||||
template<typename IsAvalanching>
|
||||
struct avalanching_value
|
||||
{
|
||||
static constexpr bool value=IsAvalanching::value;
|
||||
};
|
||||
|
||||
/* may be explicitly marked as BOOST_DEPRECATED in the future */
|
||||
template<> struct avalanching_value<void>
|
||||
{
|
||||
static constexpr bool value=true;
|
||||
};
|
||||
|
||||
template<typename Hash>
|
||||
struct hash_is_avalanching_impl<Hash,
|
||||
boost::unordered::detail::void_t<typename Hash::is_avalanching> >:
|
||||
std::true_type{};
|
||||
struct hash_is_avalanching_impl<
|
||||
Hash,
|
||||
boost::unordered::detail::void_t<typename Hash::is_avalanching>
|
||||
>:std::integral_constant<
|
||||
bool,
|
||||
avalanching_value<typename Hash::is_avalanching>::value
|
||||
>{};
|
||||
|
||||
} /* namespace detail */
|
||||
|
||||
@@ -32,8 +48,12 @@ struct hash_is_avalanching_impl<Hash,
|
||||
* when actual characterization differs from default.
|
||||
*/
|
||||
|
||||
/* hash_is_avalanching<Hash>::value is true when the type Hash::is_avalanching
|
||||
* is present, false otherwise.
|
||||
/* hash_is_avalanching<Hash>::value is:
|
||||
* - false if Hash::is_avalanching is not present.
|
||||
* - Hash::is_avalanching::value if this is present and constexpr-convertible
|
||||
* to a bool.
|
||||
* - true if Hash::is_avalanching is void (deprecated).
|
||||
* UB otherwise.
|
||||
*/
|
||||
template<typename Hash>
|
||||
struct hash_is_avalanching: detail::hash_is_avalanching_impl<Hash>::type{};
|
||||
|
||||
Reference in New Issue
Block a user