Are "enum class" members instantiated immediately or later when used?
Consider this one
开发者_JAVA技巧template<typename T>
struct A {
enum class X {
V = T()
};
};
For member classes and member functions, C++11 (and C++03) won't instantiate their definition unless we use them in a way that requires their definition. Is this true for enum class
?
// valid?
A<std::string> a;
Unfortunately, I can't check compilers, since C++11 is just out of the door and everything isn't reliable yet, it seems.
I think so. 14.7.1/1
The implicit instantiation of a class template specialization causes the implicit instantiation of the declarations, but not of the definitions or default arguments, of [...] scoped member enumerations
精彩评论