From cac706dd3c98ac280211e41041cfe3f047846d67 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Wed, 16 Mar 2016 19:27:39 +1100 Subject: [PATCH] types/traits: add remove_restrict --- types/traits.hpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/types/traits.hpp b/types/traits.hpp index 606d4b67..0281881a 100644 --- a/types/traits.hpp +++ b/types/traits.hpp @@ -20,7 +20,7 @@ #include #include -//----------------------------------------------------------------------------- +/////////////////////////////////////////////////////////////////////////////// template struct is_dereferencable : std::false_type { }; template struct is_dereferencable : std::true_type { }; template struct is_dereferencable> : std::true_type { }; @@ -28,6 +28,7 @@ template struct is_dereferencable> : std::true_t template struct is_dereferencable> : std::true_type { }; +/////////////////////////////////////////////////////////////////////////////// template struct dereferenced_type { typedef typename std::enable_if< std::is_pointer::value, @@ -42,7 +43,7 @@ template struct dereferenced_type> { typedef T t template struct dereferenced_type> { typedef T type; }; -///---------------------------------------------------------------------------- +/////////////////////////////////////////////////////////////////////////////// /// find the unsigned version of a type if one exists template struct try_unsigned @@ -51,11 +52,12 @@ struct try_unsigned }; +//----------------------------------------------------------------------------- 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 @@ -63,10 +65,13 @@ 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< std::is_integral::value && @@ -78,22 +83,32 @@ template struct is_lossless_cast : std::enable_if< >::value { }; -//----------------------------------------------------------------------------- +/////////////////////////////////////////////////////////////////////////////// template struct func_traits : public func_traits { }; +//----------------------------------------------------------------------------- template struct func_traits { typedef R return_type; }; +//----------------------------------------------------------------------------- template struct func_traits { typedef R return_type; }; +/////////////////////////////////////////////////////////////////////////////// +template struct remove_restrict { using type = T; }; +template struct remove_restrict { using type = T*; }; + +template +using remove_restrict_t = typename remove_restrict::type; + + #endif