Top "Initializer-list" questions

std::initializer_list is a special type in C++11 which is used to construct containers and other types from a list of values of the same type.

C compile error: "Variable-sized object may not be initialized"

Why do I receive the error "Variable-sized object may not be initialized" with the following code? int boardAux[length][length] = {{0}};

c compiler-errors initializer-list variable-length-array
Initializing a member array in constructor initializer

class C { public: C() : arr({1,2,3}) //doesn't compile {} /* C() : arr{1,2,3} //doesn't compile either {} */ private: int arr[3]; }; I believe the reason is …

c++ c++11 initializer-list ctor-initializer aggregate-initialization
Brace-enclosed initializer list constructor

I have class Phenotype with the following constructor: Phenotype(uint8 init[NUM_ITEMS]); I can create a Phenotype like this: …

c++ c++11 initializer-list
Can I initialize an STL vector with 10 of the same integer in an initializer list?

Can I initialize an STL vector with 10 of the same integer in an initializer list? My attempts so far have …

c++ stl constructor initializer-list
Initialize a constant sized array in an initializer list

I've got a situation which can be summarized in the following: class Test { Test(); int MySet[10]; }; is it possible to …

c++ arrays class constants initializer-list
What would a std::map extended initializer list look like?

If it even exists, what would a std::map extended initializer list look like? I've tried some combinations of... well, …

c++ c++11 dictionary initializer-list
how to assign an array from an initializer list

I have a limited knowledge about c++. I tried to compile a c++ library and when I run the make …

c++ arrays initializer-list
How do I initialize a member array with an initializer_list?

I'm getting up to speed with C++0x, and testing things out with g++ 4.6 I just tried the following code, …

c++ arrays c++11 initializer-list
Convert a vector<T> to initializer_list<T>

Everyone creates std::vector from std::initializer_list, but what about the other way around? eg. if you use a …

c++ c++11 stl initializer-list
tuple vector and initializer_list

I tried to compile the following snippets with gcc4.7 vector<pair<int,char> > vp = {{1,'a'},{2,'b'}}; //…

c++ c++11 tuples initializer-list