C++0x では、次のようになります。
std::list<std::string> colours = {"red", "blue", "green", "grey", "pink", "violet"};
標準の非0x C++で最も簡単な方法は何ですか?
C++0x では、次のようになります。
std::list<std::string> colours = {"red", "blue", "green", "grey", "pink", "violet"};
標準の非0x C++で最も簡単な方法は何ですか?
char const *x[] = {"red", "blue", "green", "grey", "pink", "violet"};
std::list<std::string> colours(x, x + sizeof(x) / sizeof(*x));
または、次のようなブースト ライブラリと関数を使用できます。list_of("a")("b")...