You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

16 lines
386 B

#pragma once
#include <type_traits>
#include <limits>
namespace detail
{
static constexpr auto cast_to_unsigned_integer_impl(bool b) { return b; }
template <typename I>
static constexpr auto cast_to_unsigned_integer_impl(I n)
{
constexpr const auto min_value = std::numeric_limits<I>::min();
return static_cast<std::make_unsigned_t<I>>(n ^ min_value);
}
} // namespace detail