I want to initialize a map
with map
-values in the following way:
std::map<int, std::map<int, int>> map =
{
{ 1, { { 1, 0 }, { 2, 1 } } },
{ 2, { { 1, 1 }, { 2, 0 } } },
};
While this compiles without any error or warning, it raises an exception stating "map/set iterators incompatible". If I remove the second pair, i.e. { 2, { { 1, 1 }, { 2, 0 } } }
, no exception is raised and map
contains one pair with key 1
and a map containing the pairs (1, 0)
and (2, 1)
as its value.
I'm sure there is a quite good reason for this (at first glance) somehow strange behavior.
Solution
Nope, there's no good reason. It turned out to be one of the beautiful bugs in Visual Studio 2013.