diff --git a/include/cuco/detail/traits.hpp b/include/cuco/detail/traits.hpp index 313f95430..87cb61c63 100644 --- a/include/cuco/detail/traits.hpp +++ b/include/cuco/detail/traits.hpp @@ -24,6 +24,15 @@ namespace cuco::detail { +template +struct is_bitwise_comparable_impl : std::false_type { +}; + +template +struct is_bitwise_comparable_impl>> + : std::true_type { +}; + template struct is_std_pair_like : cuda::std::false_type { }; diff --git a/include/cuco/pair.cuh b/include/cuco/pair.cuh index 0a804cc04..0f1a863f5 100644 --- a/include/cuco/pair.cuh +++ b/include/cuco/pair.cuh @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -141,6 +142,16 @@ template __host__ __device__ constexpr bool operator==(cuco::pair const& lhs, cuco::pair const& rhs) noexcept; +/** + * @brief A pair of bitwise comparable types is also bitwise comparable + */ +template +struct is_bitwise_comparable> + : std::integral_constant && is_bitwise_comparable_v && + sizeof(pair) == sizeof(First) + sizeof(Second)> { +}; + } // namespace cuco #include diff --git a/include/cuco/utility/traits.hpp b/include/cuco/utility/traits.hpp index 1a6252dcb..bd2a187dc 100644 --- a/include/cuco/utility/traits.hpp +++ b/include/cuco/utility/traits.hpp @@ -16,8 +16,7 @@ #pragma once -#include -#include +#include #include @@ -36,15 +35,10 @@ namespace cuco { * if a `NaN` bit pattern were used as the empty sentinel value, it may not compare bitwise equal to * other `NaN` bit patterns. * + * @note By default, only types with unique object representations are allowed */ -template -struct is_bitwise_comparable : std::false_type { -}; - -/// By default, only types with unique object representations are allowed template -struct is_bitwise_comparable>> - : std::true_type { +struct is_bitwise_comparable : detail::is_bitwise_comparable_impl { }; template