Skip to content

Commit

Permalink
- Add is_unsigned trait
Browse files Browse the repository at this point in the history
- Add make_unsigned for 128 bit integers
- Fix is_scalar traits
  • Loading branch information
igaztanaga committed Dec 31, 2023
1 parent 60f7823 commit 11930bb
Showing 1 changed file with 67 additions and 17 deletions.
84 changes: 67 additions & 17 deletions include/boost/move/detail/type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,28 @@ struct remove_cvref
{
};

//////////////////////////
// is_unsigned
//////////////////////////
template<class T> struct is_unsigned_cv { static const bool value = true; };
template <> struct is_unsigned_cv<signed char> { static const bool value = false; };
template <> struct is_unsigned_cv<signed short> { static const bool value = false; };
template <> struct is_unsigned_cv<signed int> { static const bool value = false; };
template <> struct is_unsigned_cv<signed long> { static const bool value = false; };
#ifdef BOOST_HAS_LONG_LONG
template <> struct is_unsigned_cv< ::boost::long_long_type > { static const bool value = false; };
#endif

#ifdef BOOST_HAS_INT128
template <> struct is_unsigned_cv< ::boost::int128_type > { static const bool value = false; };
#endif

template <class T>
struct is_unsigned
: is_unsigned_cv<typename remove_cv<T>::type>
{};


//////////////////////////
// make_unsigned
//////////////////////////
Expand All @@ -594,6 +616,11 @@ template <> struct make_unsigned_impl<signed long> { typedef uns
template <> struct make_unsigned_impl< ::boost::long_long_type > { typedef ::boost::ulong_long_type type; };
#endif

#ifdef BOOST_HAS_INT128
template <> struct make_unsigned_impl< ::boost::int128_type > { typedef ::boost::uint128_type type; };
#endif


template <class T>
struct make_unsigned
: make_unsigned_impl<typename remove_cv<T>::type>
Expand Down Expand Up @@ -639,6 +666,13 @@ template<> struct is_integral_cv< unsigned long>{ static const bool
template<> struct is_integral_cv< ::boost:: long_long_type>{ static const bool value = true; };
template<> struct is_integral_cv< ::boost::ulong_long_type>{ static const bool value = true; };
#endif
#ifdef BOOST_HAS_INT128
template <> struct is_integral_cv< ::boost::int128_type > { static const bool value = true; };
template <> struct is_integral_cv< ::boost::uint128_type > { static const bool value = true; };
#endif
#if defined(__cpp_char8_t) && __cpp_char8_t >= 201811L
template<> struct is_integral_cv<char8_t> { static const bool value = true; };
#endif

template<class T>
struct is_integral
Expand All @@ -660,13 +694,6 @@ template <class T, std::size_t N>
struct remove_all_extents<T[N]>
{ typedef typename remove_all_extents<T>::type type;};

//////////////////////////
// is_scalar
//////////////////////////
template<class T>
struct is_scalar
{ static const bool value = is_integral<T>::value || is_floating_point<T>::value; };

//////////////////////////
// is_void
//////////////////////////
Expand Down Expand Up @@ -732,6 +759,11 @@ struct is_nullptr_t
: is_nullptr_t_cv<typename remove_cv<T>::type>
{};

template <class T>
struct is_null_pointer
: is_nullptr_t_cv<typename remove_cv<T>::type>
{};

//////////////////////////////////////
// is_function
//////////////////////////////////////
Expand Down Expand Up @@ -802,6 +834,7 @@ struct is_arithmetic
is_integral<T>::value;
};


//////////////////////////////////////
// is_member_function_pointer
//////////////////////////////////////
Expand Down Expand Up @@ -829,21 +862,38 @@ struct is_member_function_pointer
template <class T>
struct is_enum_nonintrinsic
{
static const bool value = !is_arithmetic<T>::value &&
!is_reference<T>::value &&
!is_class_or_union<T>::value &&
!is_array<T>::value &&
!is_void<T>::value &&
!is_nullptr_t<T>::value &&
!is_member_pointer<T>::value &&
!is_pointer<T>::value &&
!is_function<T>::value;
static const bool value = !is_arithmetic<T>::value &&
!is_reference<T>::value &&
!is_class_or_union<T>::value &&
!is_array<T>::value &&
!is_void<T>::value &&
!is_nullptr_t<T>::value &&
!is_member_pointer<T>::value &&
!is_pointer<T>::value &&
!is_function<T>::value;
};
#endif

template <class T>
struct is_enum
{ static const bool value = BOOST_MOVE_IS_ENUM_IMPL(T); };
{
static const bool value = BOOST_MOVE_IS_ENUM_IMPL(T);
};


//////////////////////////
// is_scalar
//////////////////////////
template<class T>
struct is_scalar
{
static const bool value = is_arithmetic<T>::value ||
is_enum<T>::value ||
is_pointer<T>::value ||
is_member_pointer<T>::value ||
is_null_pointer<T>::value;
};


//////////////////////////////////////
// is_pod
Expand Down

0 comments on commit 11930bb

Please sign in to comment.