Enum templated template only
1 answer
Use the sign and static_assert
.
those.
template <class T>
using is_scoped_enum = std::integral_constant<bool, !std::is_convertible<T, int>{}
&& std::is_enum<T>{}>;
template <typename T>
struct myTemplate
{
static_assert( is_scoped_enum<T>{}, "Invalid type argument!" );
};
(Derived from this answer .)
Demo .
+7
source to share