traits: add try_signed convertor

This commit is contained in:
Danny Robson 2015-03-20 01:32:28 +11:00
parent 7c4604d0c7
commit 751f06dc3e

View File

@ -60,6 +60,17 @@ template <> struct try_unsigned<double> { typedef double type; };
template <> struct try_unsigned<float > { typedef float type; }; template <> struct try_unsigned<float > { typedef float type; };
///----------------------------------------------------------------------------
/// find the signed version of a type if one exists
template <typename T>
struct try_signed
{
typedef typename std::make_signed<T>::type type;
};
template <> struct try_signed<double> { typedef double type; };
template <> struct try_signed<float > { typedef float type; };
///---------------------------------------------------------------------------- ///----------------------------------------------------------------------------
/// checks if a type can be converted in all cases without modification /// checks if a type can be converted in all cases without modification
template <typename T, typename U> struct is_lossless_cast : std::enable_if< template <typename T, typename U> struct is_lossless_cast : std::enable_if<