diff --git a/Utilities/types.h b/Utilities/types.h index f5d24f4fd0..cac29175dd 100644 --- a/Utilities/types.h +++ b/Utilities/types.h @@ -461,40 +461,29 @@ using any16 = any_pod; using any32 = any_pod; using any64 = any_pod; -// Allows to define integer convertible to multiple enum types -template -struct multicast : multicast +// Allows to define integer convertible to multiple types +template +struct multicast : multicast { - static_assert(std::is_enum::value, "multicast<> error: invalid conversion type (enum type expected)"); + constexpr multicast() = default; - multicast() = default; - - template - constexpr multicast(const UT& value) - : multicast(value) - , m_value{ value } // Forbid narrowing + // Implicit conversion to desired type + constexpr operator T1() const { + return static_cast(Value); } - - constexpr operator T() const - { - // Cast to enum type - return static_cast(m_value); - } - -private: - std::underlying_type_t m_value; }; // Recursion terminator -template<> -struct multicast +template +struct multicast { - multicast() = default; - - template - constexpr multicast(const UT& value) + constexpr multicast() = default; + + // Explicit conversion to base type + explicit constexpr operator T() const { + return Value; } };