#include <iostream>
#include <array>
template< typename A >
struct someClass{
enum class State {
sA,
sB,
sC
};
static const std::array<State,3> the_states;
};
template<typename A>
const std::array<typename someClass<A>::State,3> someClass<A>::the_states = {
someClass<A>::State::sA,
someClass<A>::State::sB,
someClass<A>::State::sC
};
int main() {
for( auto i : someClass<int>::the_states) {
switch(i) {
case someClass<int>::State::sA:
std::cout << "sA" << std::endl;
break;
case someClass<int>::State::sB:
std::cout << "sB" << std::endl;
break;
case someClass<int>::State::sC:
std::cout << "sC" << std::endl;
break;
}
}
}
请注意,你可以以零敲碎打的方式终止名单,因为0人不能被转换成一个大类国家。
巴哈教徒,当我对真实的Dave先生的回答置之不理的时候。