I think testing if it is an enum and not implicitly convertible to the underlying type should do the trick.
template <typename T, bool B = std::is_enum<T>::value>
struct is_scoped_enum : std::false_type {};
template <typename T>
struct is_scoped_enum<T, true>
: std::integral_constant<bool,
!std::is_convertible<T, typename std::underlying_type<T>::type>::value> {};
Related Contents:
- Is it possible to figure out the parameter type and return type of a lambda?
- Conveniently Declaring Compile-Time Strings in C++
- Compile time string hashing
- Why is there not an std::is_struct type trait?
- Find out whether a C++ object is callable
- Check traits for all variadic template arguments
- check variadic templates parameters for uniqueness
- Checking a member exists, possibly in a base class, C++11 version
- Enumerate over an enum in C++
- What do compilers do with compile-time branching?
- False positive with is_copy_constructible on vector
- What is decltype with two arguments?
- How can I expand call to variadic template base classes?
- Allow for Range-Based For with enum classes?
- How can I output the value of an enum class in C++11
- Enum vs Strongly typed enum
- Which cannot be implemented without compiler hooks?
- Equivalent of “using namespace X” for scoped enumerations?
- What are Aggregates and PODs and how/why are they special?
- Why C++11 in-class initializer cannot use parentheses?
- c++11 Return value optimization or move? [duplicate]
- SFINAE working in return type but not as template parameter
- Passing object by reference to std::thread in C++11
- When can outer braces be omitted in an initializer list?
- How do I use a custom deleter with a std::unique_ptr member?
- Why is conversion from string constant to ‘char*’ valid in C but invalid in C++
- What is the type of lambda when deduced with “auto” in C++11?
- How do I combine hash values in C++0x?
- How does `is_base_of` work?
- What does auto&& tell us?
- Why do std::shared_ptr work
- Pretty-print std::tuple
- std::next_permutation Implementation Explanation
- How to use range-based for() loop with std::map?
- How to initialize std::array elegantly if T is not default constructible?
- Can I use C++11 with Xcode?
- What is std::promise?
- How can I iterate over a packed variadic template argument list?
- Can C++ code be valid in both C++03 and C++11 but do different things?
- What do each memory_order mean?
- std::auto_ptr to std::unique_ptr
- Why can we use `std::move` on a `const` object?
- lvalue to rvalue implicit conversion
- Populate An Array Using Constexpr at Compile-time
- Template specialization and enable_if problems [duplicate]
- Extending enums in C++?
- C++11 Implementation of Spinlock using header “
- How to enable C++11 in CLion?
- Why should I use std::async?
- Why is there no piecewise tuple construction?