Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions include/boost/type_traits/is_signed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/remove_cv.hpp>
#include <boost/type_traits/is_enum.hpp>
#include <boost/core/underlying_type.hpp>
#include <climits>

namespace boost {
Expand All @@ -25,6 +26,18 @@ namespace boost {

namespace detail{

template <class no_cv_t, bool is_enum>
struct is_signed_values_underlying_type
{
typedef no_cv_t underlying_type;
};

template <class no_cv_t>
struct is_signed_values_underlying_type<no_cv_t, true>
{
typedef typename ::boost::underlying_type<no_cv_t>::type underlying_type;
};

template <class T>
struct is_signed_values
{
Expand All @@ -34,14 +47,15 @@ struct is_signed_values
// the correct answer.
//
typedef typename remove_cv<T>::type no_cv_t;
static const no_cv_t minus_one = (static_cast<no_cv_t>(-1));
static const no_cv_t zero = (static_cast<no_cv_t>(0));
typedef typename is_signed_values_underlying_type<no_cv_t, ::boost::is_enum<T>::value>::underlying_type underlying_type;

static const underlying_type minus_one = (static_cast<underlying_type>(-1));
static const underlying_type zero = (static_cast<underlying_type>(0));
};

template <class T>
struct is_signed_helper
{
typedef typename remove_cv<T>::type no_cv_t;
BOOST_STATIC_CONSTANT(bool, value = (!(::boost::detail::is_signed_values<T>::minus_one > boost::detail::is_signed_values<T>::zero)));
};

Expand Down
19 changes: 17 additions & 2 deletions include/boost/type_traits/is_unsigned.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/is_enum.hpp>
#include <boost/type_traits/remove_cv.hpp>
#include <boost/core/underlying_type.hpp>

#include <climits>

Expand All @@ -26,6 +27,18 @@ namespace boost {

namespace detail{

template <class no_cv_t, bool is_enum>
struct is_unsigned_values_underlying_type
{
typedef no_cv_t underlying_type;
};

template <class no_cv_t>
struct is_unsigned_values_underlying_type<no_cv_t, true>
{
typedef typename ::boost::underlying_type<no_cv_t>::type underlying_type;
};

template <class T>
struct is_unsigned_values
{
Expand All @@ -35,8 +48,10 @@ struct is_unsigned_values
// the correct answer.
//
typedef typename remove_cv<T>::type no_cv_t;
static const no_cv_t minus_one = (static_cast<no_cv_t>(-1));
static const no_cv_t zero = (static_cast<no_cv_t>(0));
typedef typename is_unsigned_values_underlying_type<no_cv_t, ::boost::is_enum<T>::value>::underlying_type underlying_type;

static const underlying_type minus_one = (static_cast<underlying_type>(-1));
static const underlying_type zero = (static_cast<underlying_type>(0));
};

template <class T>
Expand Down