types/traits: add try_underlying
This commit is contained in:
parent
34aed6c74d
commit
c23d2e38f3
@ -120,6 +120,20 @@ template <typename ValueT>
|
||||
using try_signed_t = typename try_signed<ValueT>::type;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
namespace cruft {
|
||||
template <typename ValueT, typename = void>
|
||||
struct try_underlying { using type = ValueT; };
|
||||
|
||||
|
||||
template <typename ValueT>
|
||||
struct try_underlying<
|
||||
ValueT,
|
||||
std::void_t<std::underlying_type_t<ValueT>>
|
||||
> { using type = std::underlying_type<ValueT>; };
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// checks if a type can be converted in all cases without modification
|
||||
template <typename T, typename U> struct is_lossless_cast : std::enable_if<
|
||||
|
Loading…
Reference in New Issue
Block a user