From 751f06dc3eeeb72e8ada322d023c828c434e19df Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Fri, 20 Mar 2015 01:32:28 +1100 Subject: [PATCH] traits: add try_signed convertor --- types/traits.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/types/traits.hpp b/types/traits.hpp index 4c47e119..b711fd66 100644 --- a/types/traits.hpp +++ b/types/traits.hpp @@ -60,6 +60,17 @@ template <> struct try_unsigned { typedef double type; }; template <> struct try_unsigned { typedef float type; }; +///---------------------------------------------------------------------------- +/// find the signed version of a type if one exists +template +struct try_signed +{ + typedef typename std::make_signed::type type; +}; + +template <> struct try_signed { typedef double type; }; +template <> struct try_signed { typedef float type; }; + ///---------------------------------------------------------------------------- /// checks if a type can be converted in all cases without modification template struct is_lossless_cast : std::enable_if<