From c23d2e38f3d60ab7e0a619523f804befc027e69d Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Fri, 11 Sep 2020 13:36:17 +1000 Subject: [PATCH] types/traits: add `try_underlying` --- types/traits.hpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/types/traits.hpp b/types/traits.hpp index 45e48c2a..b64f875f 100644 --- a/types/traits.hpp +++ b/types/traits.hpp @@ -120,6 +120,20 @@ template using try_signed_t = typename try_signed::type; +/////////////////////////////////////////////////////////////////////////////// +namespace cruft { + template + struct try_underlying { using type = ValueT; }; + + + template + struct try_underlying< + ValueT, + std::void_t> + > { using type = std::underlying_type; }; +} + + /////////////////////////////////////////////////////////////////////////////// /// checks if a type can be converted in all cases without modification template struct is_lossless_cast : std::enable_if<