Skip to content

Commit

Permalink
Use SizedUnsignedType_t to pick UnsignedType for uniform_integer_dist…
Browse files Browse the repository at this point in the history
…ribution

The previously used `make_unsigned` approach combined with the overload
set of `extendedMult` caused compilation issues on MacOS platform. By
forcing the selection to be one of `std::uintX_t` types we don't need
to complicate the overload set further.
  • Loading branch information
horenmar committed Apr 3, 2024
1 parent c13ddcb commit 41f2ce0
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions src/catch2/internal/catch_uniform_integer_distribution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,6 @@

namespace Catch {

namespace Detail {
// Indirection to enable make_unsigned<bool> behaviour.
template <typename T>
struct make_unsigned {
using type = std::make_unsigned_t<T>;
};

template <>
struct make_unsigned<bool> {
using type = uint8_t;
};

template <typename T>
using make_unsigned_t = typename make_unsigned<T>::type;
}

/**
* Implementation of uniform distribution on integers.
*
Expand All @@ -44,7 +28,7 @@ template <typename IntegerType>
class uniform_integer_distribution {
static_assert(std::is_integral<IntegerType>::value, "...");

using UnsignedIntegerType = Detail::make_unsigned_t<IntegerType>;
using UnsignedIntegerType = Detail::SizedUnsignedType_t<sizeof(IntegerType)>;

// Only the left bound is stored, and we store it converted to its
// unsigned image. This avoids having to do the conversions inside
Expand Down

0 comments on commit 41f2ce0

Please sign in to comment.