Although I much enjoy the new features in C++11, sometimes I feel like I'm missing some of its subtleties.
Initializing the int array works fine, initializing the Element2 vector works fine, but initializing the Element2 array fails. I think the correct syntax should be the uncommented line, but none of the initialization attempts have succeeded for me.
#include <array>
#include <vector>
class Element2
{
public:
Element2(unsigned int Input) {}
Element2(Element2 const &Other) {}
};
class Test
{
public:
Test(void) :
Array{{4, 5, 6}},
Array2{4, 5},
//Array3{4, 5, 6}
Array3{{4, 5, 6}}
//Array3{{4}, {5}, {6}}
//Array3{{{4}, {5}, {6}}}
//Array3{Element2{4}, Element2{5}, Element2{6}}
//Array3{{Element2{4}, Element2{5}, Element2{6}}}
//Array3{{{Element2{4}}, {Element2{5}}, {Element2{6}}}}
{}
private:
std::array<int, 3> Array;
std::vector<Element2> Array2;
std::array<Element2, 3> Array3;
};
int main(int argc, char **argv)
{
Test();
return 0;
}
I've tried this on g++ 4.6.1 and 4.6.2 under MinGW.
How should I correctly go about initializing this array? Is it possible?