#ifndef _H_LIBCX_STL_MAKE_UNSIGNED #define _H_LIBCX_STL_MAKE_UNSIGNED #include #include #if __has_builtin(__make_unsigned) template using __make_unsigned_t = __make_unsigned(_Tp); #else using __unsigned_types = __type_list; template ::value || is_enum<_Tp>::value> struct __make_unsigned{}; template struct __make_unsigned<_Tp, true> { typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type; }; // clang-format off template <> struct __make_unsigned {}; template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;}; template <> struct __make_unsigned {typedef unsigned short type;}; template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;}; template <> struct __make_unsigned {typedef unsigned int type;}; template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;}; template <> struct __make_unsigned {typedef unsigned long type;}; template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;}; template <> struct __make_unsigned {typedef unsigned long long type;}; # if _CX_HAS_INT128 template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;}; template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;}; # endif // clang-format on template using __make_unsigned_t = __copy_cv_t<_Tp, typename __make_unsigned<__remove_cv_t<_Tp>>::type>; #endif // __has_builtin(__make_unsigned) template struct make_unsigned { using type = __make_unsigned_t<_Tp>; }; template using make_unsigned_t = __make_unsigned_t<_Tp>; template __make_unsigned_t<_Tp> __to_unsigned_like(_Tp __x) { return static_cast<__make_unsigned_t<_Tp>>(__x); } template using __copy_unsigned_t = __conditional_t::value, __make_unsigned_t<_Up>, _Up>; #endif // _H_LIBCX_STL_MAKE_UNSIGNED