Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ Can not initialize with {...}

I am using VS2012, and I wanted to include the following map:

#include<iostream>
#include<map>

std::map<int, int> code_map = {
  {65, 97},
  {66, 98},
  {67, 99},
  {68, 100},
  {69, 101},
  {70, 102},  
};

However, the IDE tells me

IntelliSense: Initialization with "{...}" invalid for object of type ""std::map, std::allocator>>""

Does anybody see why this error occurs? I guess that I am using C++11 if I use VS2012, so I thought that would work.

Thank you for the help.

like image 333
tmighty Avatar asked Nov 19 '13 21:11

tmighty


1 Answers

Visual Studio 2012 doesn't support initializer lists. See this for the C++11 features it does support: http://msdn.microsoft.com/en-us/library/vstudio/hh567368%28v=vs.120%29.aspx

like image 77
user2093113 Avatar answered Oct 07 '22 22:10

user2093113