using max_size_t = std::ranges::__detail::__max_size_type;
using max_diff_t = std::ranges::__detail::__max_diff_type;
using rep_t = max_size_t::__rep;
+#if __SIZEOF_INT128__
+using signed_rep_t = __int128;
+#else
+using signed_rep_t = long long;
+#endif
static_assert(sizeof(max_size_t) == sizeof(max_diff_t));
+static_assert(sizeof(rep_t) == sizeof(signed_rep_t));
static_assert(std::regular<max_size_t>);
static_assert(std::totally_ordered<max_size_t>);
static_assert(max_diff_t(3) % -2 == 1);
static_assert(max_diff_t(-3) << 1 == -6);
static_assert(max_diff_t(-3) >> 1 == -2);
+ static_assert(max_diff_t(-3) >> 2 == -1);
+ static_assert(max_diff_t(-3) >> 10 == -1);
static_assert(max_diff_t(3) >> 1 == 1);
static_assert(max_diff_t(3) >> 2 == 0);
void
test02()
{
- using hw_type = std::conditional_t<signed_p, signed rep_t, rep_t>;
+ using hw_type = std::conditional_t<signed_p, signed_rep_t, rep_t>;
using max_type = std::conditional_t<signed_p, max_diff_t, max_size_t>;
using shorten_type = std::conditional_t<shorten_p, hw_type, max_type>;
const int hw_type_bit_size = sizeof(hw_type) * __CHAR_BIT__;
void
test03()
{
- using hw_type = std::conditional_t<signed_p, signed rep_t, rep_t>;
+ using hw_type = std::conditional_t<signed_p, signed_rep_t, rep_t>;
using max_type = std::conditional_t<signed_p, max_diff_t, max_size_t>;
using base_type = std::conditional_t<toggle_base_p, hw_type, max_type>;
constexpr int hw_type_bit_size = sizeof(hw_type) * __CHAR_BIT__;