Wednesday, June 26, 2019

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

plot explanation - Why did Peaches&#39; mom hang on the tree? - Movies &amp; TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...