Initializing a map card with a list of initializers in VS 2013

I am trying to initialize a map of cards using C ++ 11. My compiler is VS 2013 Express.

unordered_map<EnumType, unordered_map<string, string>> substitutions = { { Record::BasementType, { { "0", "" }, { "1", "Slab or pier" }, { "2", "Crawl" } } }, { Record::BuildingStyle, { { "0", "" }, { "1", "Ranch" }, { "2", "Raised ranch" } } }, // ... and so on }; 

It compiles, but I get a breakpoint inside ntdll.dll. However, a simplified version of this code:

 unordered_map<EnumType, unordered_map<string, string>> substitutions = { { Record::BasementType, { { "0", "" }, { "1", "Slab or pier" }, { "2", "Crawl" } } }, // *nothing more* }; 

works correctly.

Why doesn't this work when I have more than one pair on my card? How to do it better?

+7
c ++ c ++ 11 visual-studio-2013 stl
source share
1 answer

This is a known compiler error http://connect.microsoft.com/VisualStudio/feedback/details/800104/ . The compiler gets confused temporarily in the initializer lists and can even destroy an individual object repeatedly. Since this is silent bad code, I asked the compiler command to set the priority to fix it.

+17
source share

All Articles