mardi 30 décembre 2014

What is the difference between these two forms of list initialization for std::map?

I have tested the following two forms with clang and they are both accepted:



using IntMap = std::map<int, int>;

IntMap map1 {{
{1, 1},
{2, 2},
{3, 3},
{4, 4}
}};

IntMap map2 {
{1, 1},
{2, 2},
{3, 3},
{4, 4}
};


On Visual Studio 2013, the latter example fails to compile stating there is no constructor in map that takes 4 arguments.


I'm assuming both are actually valid. What is the difference between the two? Why doesn't the second example work on Visual Studio 2013?


Aucun commentaire:

Enregistrer un commentaire