__INT_N(__GLIBCXX_TYPE_INT_N_3)
#endif
+#if defined __STRICT_ANSI__ && defined __SIZEOF_INT128__
+// In strict modes __GLIBCXX_TYPE_INT_N_0 is not defined for __int128,
+// but we want to always treat signed/unsigned __int128 as integral types.
+__INT_N(__int128)
+#endif
+
#undef __INT_N
//
{ enum { __width = __GLIBCXX_BITSIZE_INT_N_3 }; };
#endif
-#if defined __STRICT_ANSI__ && defined __SIZEOF_INT128__
- // In strict modes __is_integer<__int128> is false,
- // but we want to allow memcpy between signed/unsigned __int128.
- __extension__
- template<>
- struct __memcpyable_integer<__int128> { enum { __width = 128 }; };
- __extension__
- template<>
- struct __memcpyable_integer<unsigned __int128> { enum { __width = 128 }; };
-#endif
-
#if _GLIBCXX_DOUBLE_IS_IEEE_BINARY64 && _GLIBCXX_LDOUBLE_IS_IEEE_BINARY64
template<>
struct __memcpyable<double*, long double*> { enum { __value = true }; };
= make_signed_t<decltype(std::declval<_Tp>() - std::declval<_Tp>())>;
};
-#if defined __STRICT_ANSI__ && defined __SIZEOF_INT128__
- // __int128 is incrementable even if !integral<__int128>
- template<>
- struct incrementable_traits<__int128>
- { using difference_type = __int128; };
-
- template<>
- struct incrementable_traits<unsigned __int128>
- { using difference_type = __int128; };
-#endif
-
namespace __detail
{
// An iterator such that iterator_traits<_Iter> names a specialization
class __max_diff_type;
class __max_size_type;
- __extension__
- template<typename _Tp>
- concept __is_signed_int128
-#if __SIZEOF_INT128__
- = same_as<_Tp, __int128>;
-#else
- = false;
-#endif
-
- __extension__
- template<typename _Tp>
- concept __is_unsigned_int128
-#if __SIZEOF_INT128__
- = same_as<_Tp, unsigned __int128>;
-#else
- = false;
-#endif
-
template<typename _Tp>
concept __cv_bool = same_as<const volatile _Tp, const volatile bool>;
template<typename _Tp>
concept __integral_nonbool = integral<_Tp> && !__cv_bool<_Tp>;
- template<typename _Tp>
- concept __is_int128 = __is_signed_int128<_Tp> || __is_unsigned_int128<_Tp>;
-
template<typename _Tp>
concept __is_integer_like = __integral_nonbool<_Tp>
- || __is_int128<_Tp>
|| same_as<_Tp, __max_diff_type> || same_as<_Tp, __max_size_type>;
template<typename _Tp>
concept __is_signed_integer_like = signed_integral<_Tp>
- || __is_signed_int128<_Tp>
|| same_as<_Tp, __max_diff_type>;
} // namespace ranges::__detail
public:
__max_size_type() = default;
- template<typename _Tp> requires integral<_Tp> || __is_int128<_Tp>
+ template<typename _Tp> requires integral<_Tp>
constexpr
__max_size_type(_Tp __i) noexcept
: _M_val(__i), _M_msb(__i < 0)
constexpr explicit
__max_size_type(const __max_diff_type& __d) noexcept;
- template<typename _Tp> requires integral<_Tp> || __is_int128<_Tp>
+ template<typename _Tp> requires integral<_Tp>
constexpr explicit
operator _Tp() const noexcept
{ return _M_val; }
return *this;
}
- template<typename _Tp> requires integral<_Tp> || __is_int128<_Tp>
+ template<typename _Tp> requires integral<_Tp>
friend constexpr _Tp&
operator+=(_Tp& __a, const __max_size_type& __b) noexcept
{ return (__a = static_cast<_Tp>(__a + __b)); }
- template<typename _Tp> requires integral<_Tp> || __is_int128<_Tp>
+ template<typename _Tp> requires integral<_Tp>
friend constexpr _Tp&
operator-=(_Tp& __a, const __max_size_type& __b) noexcept
{ return (__a = static_cast<_Tp>(__a - __b)); }
- template<typename _Tp> requires integral<_Tp> || __is_int128<_Tp>
+ template<typename _Tp> requires integral<_Tp>
friend constexpr _Tp&
operator*=(_Tp& __a, const __max_size_type& __b) noexcept
{ return (__a = static_cast<_Tp>(__a * __b)); }
- template<typename _Tp> requires integral<_Tp> || __is_int128<_Tp>
+ template<typename _Tp> requires integral<_Tp>
friend constexpr _Tp&
operator/=(_Tp& __a, const __max_size_type& __b) noexcept
{ return (__a = static_cast<_Tp>(__a / __b)); }
- template<typename _Tp> requires integral<_Tp> || __is_int128<_Tp>
+ template<typename _Tp> requires integral<_Tp>
friend constexpr _Tp&
operator%=(_Tp& __a, const __max_size_type& __b) noexcept
{ return (__a = static_cast<_Tp>(__a % __b)); }
- template<typename _Tp> requires integral<_Tp> || __is_int128<_Tp>
+ template<typename _Tp> requires integral<_Tp>
friend constexpr _Tp&
operator&=(_Tp& __a, const __max_size_type& __b) noexcept
{ return (__a = static_cast<_Tp>(__a & __b)); }
- template<typename _Tp> requires integral<_Tp> || __is_int128<_Tp>
+ template<typename _Tp> requires integral<_Tp>
friend constexpr _Tp&
operator|=(_Tp& __a, const __max_size_type& __b) noexcept
{ return (__a = static_cast<_Tp>(__a | __b)); }
- template<typename _Tp> requires integral<_Tp> || __is_int128<_Tp>
+ template<typename _Tp> requires integral<_Tp>
friend constexpr _Tp&
operator^=(_Tp& __a, const __max_size_type& __b) noexcept
{ return (__a = static_cast<_Tp>(__a ^ __b)); }
- template<typename _Tp> requires integral<_Tp> || __is_int128<_Tp>
+ template<typename _Tp> requires integral<_Tp>
friend constexpr _Tp&
operator<<=(_Tp& __a, const __max_size_type& __b) noexcept
{ return (__a = static_cast<_Tp>(__a << __b)); }
- template<typename _Tp> requires integral<_Tp> || __is_int128<_Tp>
+ template<typename _Tp> requires integral<_Tp>
friend constexpr _Tp&
operator>>=(_Tp& __a, const __max_size_type& __b) noexcept
{ return (__a = static_cast<_Tp>(__a >> __b)); }
public:
__max_diff_type() = default;
- template<typename _Tp> requires integral<_Tp> || __is_int128<_Tp>
+ template<typename _Tp> requires integral<_Tp>
constexpr
__max_diff_type(_Tp __i) noexcept
: _M_rep(__i)
: _M_rep(__d)
{ }
- template<typename _Tp> requires integral<_Tp> || __is_int128<_Tp>
+ template<typename _Tp> requires integral<_Tp>
constexpr explicit
operator _Tp() const noexcept
{ return static_cast<_Tp>(_M_rep); }
return *this;
}
- template<typename _Tp> requires integral<_Tp> || __is_int128<_Tp>
+ template<typename _Tp> requires integral<_Tp>
friend constexpr _Tp&
operator+=(_Tp& __a, const __max_diff_type& __b) noexcept
{ return (__a = static_cast<_Tp>(__a + __b)); }
- template<typename _Tp> requires integral<_Tp> || __is_int128<_Tp>
+ template<typename _Tp> requires integral<_Tp>
friend constexpr _Tp&
operator-=(_Tp& __a, const __max_diff_type& __b) noexcept
{ return (__a = static_cast<_Tp>(__a - __b)); }
- template<typename _Tp> requires integral<_Tp> || __is_int128<_Tp>
+ template<typename _Tp> requires integral<_Tp>
friend constexpr _Tp&
operator*=(_Tp& __a, const __max_diff_type& __b) noexcept
{ return (__a = static_cast<_Tp>(__a * __b)); }
- template<typename _Tp> requires integral<_Tp> || __is_int128<_Tp>
+ template<typename _Tp> requires integral<_Tp>
friend constexpr _Tp&
operator/=(_Tp& __a, const __max_diff_type& __b) noexcept
{ return (__a = static_cast<_Tp>(__a / __b)); }
- template<typename _Tp> requires integral<_Tp> || __is_int128<_Tp>
+ template<typename _Tp> requires integral<_Tp>
friend constexpr _Tp&
operator%=(_Tp& __a, const __max_diff_type& __b) noexcept
{ return (__a = static_cast<_Tp>(__a % __b)); }
- template<typename _Tp> requires integral<_Tp> || __is_int128<_Tp>
+ template<typename _Tp> requires integral<_Tp>
friend constexpr _Tp&
operator&=(_Tp& __a, const __max_diff_type& __b) noexcept
{ return (__a = static_cast<_Tp>(__a & __b)); }
- template<typename _Tp> requires integral<_Tp> || __is_int128<_Tp>
+ template<typename _Tp> requires integral<_Tp>
friend constexpr _Tp&
operator|=(_Tp& __a, const __max_diff_type& __b) noexcept
{ return (__a = static_cast<_Tp>(__a | __b)); }
- template<typename _Tp> requires integral<_Tp> || __is_int128<_Tp>
+ template<typename _Tp> requires integral<_Tp>
friend constexpr _Tp&
operator^=(_Tp& __a, const __max_diff_type& __b) noexcept
{ return (__a = static_cast<_Tp>(__a ^ __b)); }
- template<typename _Tp> requires integral<_Tp> || __is_int128<_Tp>
+ template<typename _Tp> requires integral<_Tp>
friend constexpr _Tp&
operator<<=(_Tp& __a, const __max_diff_type& __b) noexcept
{ return (__a = static_cast<_Tp>(__a << __b)); }
- template<typename _Tp> requires integral<_Tp> || __is_int128<_Tp>
+ template<typename _Tp> requires integral<_Tp>
friend constexpr _Tp&
operator>>=(_Tp& __a, const __max_diff_type& __b) noexcept
{ return (__a = static_cast<_Tp>(__a >> __b)); }
__to_unsigned_like(_Tp __t) noexcept
{ return static_cast<make_unsigned_t<_Tp>>(__t); }
-#if defined __STRICT_ANSI__ && defined __SIZEOF_INT128__
- constexpr unsigned __int128
- __to_unsigned_like(__int128 __t) noexcept
- { return __t; }
-
- constexpr unsigned __int128
- __to_unsigned_like(unsigned __int128 __t) noexcept
- { return __t; }
-#endif
-
template<typename _Tp>
using __make_unsigned_like_t
= decltype(__detail::__to_unsigned_like(std::declval<_Tp>()));
else
return static_cast<make_signed_t<__size_type>>(__size);
}
-#if defined __STRICT_ANSI__ && defined __SIZEOF_INT128__
- // For strict-ansi modes integral<__int128> is false
- else if constexpr (__detail::__is_int128<__size_type>)
- return static_cast<__int128>(__size);
-#endif
else // Must be one of __max_diff_type or __max_size_type.
return __detail::__max_diff_type(__size);
}
__size_to_integer(unsigned __GLIBCXX_TYPE_INT_N_3 __n) { return __n; }
#endif
+#if defined(__STRICT_ANSI__) && defined(__SIZEOF_INT128__)
+ __extension__ inline _GLIBCXX_CONSTEXPR __int128
+ __size_to_integer(__int128 __n) { return __n; }
+ __extension__ inline _GLIBCXX_CONSTEXPR unsigned __int128
+ __size_to_integer(unsigned __int128 __n) { return __n; }
+#endif
+
inline _GLIBCXX_CONSTEXPR long long
__size_to_integer(float __n) { return (long long)__n; }
inline _GLIBCXX_CONSTEXPR long long
_GLIBCXX_INT_N_TRAITS(__GLIBCXX_TYPE_INT_N_3, __GLIBCXX_BITSIZE_INT_N_3)
#endif
-#if defined __STRICT_ANSI__ && defined __SIZEOF_INT128__
- // In strict modes __is_integer<__int128> is false,
- // but we still want to define __numeric_traits_integer<__int128>.
- _GLIBCXX_INT_N_TRAITS(__int128, 128)
-#endif
-
#undef _GLIBCXX_INT_N_TRAITS
#if __cplusplus >= 201103L
_GLIBCXX_TO_CHARS(signed __GLIBCXX_TYPE_INT_N_3)
_GLIBCXX_TO_CHARS(unsigned __GLIBCXX_TYPE_INT_N_3)
#endif
+#if defined __SIZEOF_INT128__ && defined __STRICT_ANSI__
+_GLIBCXX_TO_CHARS(signed __int128)
+_GLIBCXX_TO_CHARS(unsigned __int128)
+#endif
#undef _GLIBCXX_TO_CHARS
// _GLIBCXX_RESOLVE_LIB_DEFECTS
__align, __nfill, __fill_char);
}
-#if defined __SIZEOF_INT128__ && defined __STRICT_ANSI__
- template<typename _Tp>
- using make_unsigned_t
- = typename __conditional_t<(sizeof(_Tp) <= sizeof(long long)),
- std::make_unsigned<_Tp>,
- type_identity<unsigned __int128>>::type;
-
- // std::to_chars is not overloaded for int128 in strict mode.
- template<typename _Int>
- static to_chars_result
- to_chars(char* __first, char* __last, _Int __value, int __base)
- { return std::__to_chars_i<_Int>(__first, __last, __value, __base); }
-#endif
-
_Spec<_CharT> _M_spec{};
};
#define __INT_N_U201103(TYPE)
#endif
-#if !defined(__STRICT_ANSI__)
#ifdef __GLIBCXX_TYPE_INT_N_0
__INT_N(__GLIBCXX_TYPE_INT_N_0, __GLIBCXX_BITSIZE_INT_N_0,
__INT_N_201103 (__GLIBCXX_TYPE_INT_N_0),
__INT_N_U201103 (__GLIBCXX_TYPE_INT_N_3))
#endif
-#elif defined __STRICT_ANSI__ && defined __SIZEOF_INT128__
+#if defined __STRICT_ANSI__ && defined __SIZEOF_INT128__
__INT_N(__int128, 128,
__INT_N_201103 (__int128),
__INT_N_U201103 (__int128))
struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_3>
: public true_type { };
#endif
+
+#if defined __SIZEOF_INT128__ && defined __STRICT_ANSI__
+ __extension__
+ template<>
+ struct __is_integral_helper<__int128>
+ : public true_type { };
+
+ __extension__
+ template<>
+ struct __is_integral_helper<unsigned __int128>
+ : public true_type { };
+#endif
+
/// @endcond
/// is_integral
struct __make_unsigned<__GLIBCXX_TYPE_INT_N_3>
{ using __type = unsigned __GLIBCXX_TYPE_INT_N_3; };
#endif
+#if defined __SIZEOF_INT128__ && defined __STRICT_ANSI__
+ __extension__
+ template<>
+ struct __make_unsigned<__int128>
+ { using __type = unsigned __int128; };
+#endif
// Select between integral and enum: not possible to be both.
template<typename _Tp,
struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_3>
{ using __type = __GLIBCXX_TYPE_INT_N_3; };
#endif
+#if defined __SIZEOF_INT128__ && defined __STRICT_ANSI__
+ __extension__
+ template<>
+ struct __make_signed<unsigned __int128>
+ { using __type = __int128; };
+#endif
// Select between integral and enum: not possible to be both.
template<typename _Tp,