Unless I am mistaken, it should be possible to create a std:array in these ways:
std::array<std::string, 2> strings = { "a", "b" };
std::array<std::string, 2> strings({ "a", "b" });
And yet, using GCC 4.6.1 I am unable to get any of these to work. The compiler simply says:
expected primary-expression before ',' token
and yet initialization lists work just fine with std::vector. So which is it? Am I mistaken to think std::array should accept initialization lists, or has the GNU Standard C++ Library team goofed?
std::string
with string literals. Have you tried wrapping the string literals withstd::string()
? – Lizabethlizard