Sunday, 3 July 2016

c++ - tuple vector and initializer_list

I tried to compile the following snippets with gcc4.7



vector > vp = {{1,'a'},{2,'b'}};
//For pair vector, it works like a charm.

vector > vt = {{1,0.1,'a'},{2,4.2,'b'}};


However, for the vector of tuples, the compiler complains:





error: converting to ‘std::tuple’ from initializer list would use explicit constructor ‘constexpr std::tuple< >::tuple(_UElements&& ...) [with _UElements = {int, double, char}; = void; _Elements = {int, double, char}]’




The error info spilled by the compiler is total gibberish for me, and I have no idea how were the constructors of tuple implemented, yet I do know they're totally okay with uniform initialization (like: tuple{1,2.2,'X'}), therefore, I wonder if the problem I encountered is only a TODO of the compiler or it's something defined by the C++11 standard.

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...