I've this C++14 code:
#include <type_traits>
struct f1 {
enum struct e { a };
};
struct f2 {
enum struct e {};
};
template <typename T>
struct my_struct {
using e = typename T::e;
my_struct()
: _e{e::a} {} // e::a used here
e _e;
};
int main() {
my_struct<f1> a;
my_struct<f2> b; // compilation fails
}
Obviously the compilation fails with something like 'a' is not a member of 'my_struct<f2>::e'
. I really would like to add some static assertions to my_struct
, to add a custom error message. First of all, I can check if e
is actually an enumeration:
static_assert(std::is_enum<e>::value, "my message");
Then, what should I add to statically assert that e::a
is defined?