Skip to content

Commit 2ddb85b

Browse files
Error when users specialize BaseTraits but not numeric_limits (NVIDIA#3836)
1 parent 08e79fd commit 2ddb85b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cub/cub/util_type.cuh

+9
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,9 @@ struct BaseTraits
793793
template <typename _UnsignedBits, typename T>
794794
struct BaseTraits<UNSIGNED_INTEGER, _UnsignedBits, T>
795795
{
796+
static_assert(::cuda::std::numeric_limits<T>::is_specialized,
797+
"Please also specialize cuda::std::numeric_limits for T");
798+
796799
using UnsignedBits = _UnsignedBits;
797800
static constexpr UnsignedBits LOWEST_KEY = UnsignedBits(0);
798801
static constexpr UnsignedBits MAX_KEY = UnsignedBits(-1);
@@ -830,6 +833,9 @@ struct BaseTraits<UNSIGNED_INTEGER, _UnsignedBits, T>
830833
template <typename _UnsignedBits, typename T>
831834
struct BaseTraits<SIGNED_INTEGER, _UnsignedBits, T>
832835
{
836+
static_assert(::cuda::std::numeric_limits<T>::is_specialized,
837+
"Please also specialize cuda::std::numeric_limits for T");
838+
833839
using UnsignedBits = _UnsignedBits;
834840

835841
static constexpr UnsignedBits HIGH_BIT = UnsignedBits(1) << ((sizeof(UnsignedBits) * 8) - 1);
@@ -865,6 +871,9 @@ struct BaseTraits<SIGNED_INTEGER, _UnsignedBits, T>
865871
template <typename _UnsignedBits, typename T>
866872
struct BaseTraits<FLOATING_POINT, _UnsignedBits, T>
867873
{
874+
static_assert(::cuda::std::numeric_limits<T>::is_specialized,
875+
"Please also specialize cuda::std::numeric_limits for T");
876+
868877
using UnsignedBits = _UnsignedBits;
869878

870879
static constexpr UnsignedBits HIGH_BIT = UnsignedBits(1) << ((sizeof(UnsignedBits) * 8) - 1);

0 commit comments

Comments
 (0)