What is the difference between these two forms of list initialization for std :: map?
I've 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}
};
In Visual Studio 2013, the last example does not compile, stating that there is no constructor on the map that takes 4 arguments.
I am assuming that both are valid. What's the difference between the two? Why doesn't the second example work on Visual Studio 2013?
+3
source to share
1 answer
As TC noted in the comments, both are legal. The first style can be weird , but if the second doesn't work for you in VS2013, then it's a compiler error) or partial implementation).
+1
source to share