Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Initializer list not working with vector in Visual Studio 2012? [duplicate]

Tags:

Possible Duplicate:
C++11 features in Visual Studio 2012

So I was reading up on C++11 initializer lists today via Wikipedia and saw that C++11 supports the following syntax for the standard containers:

std::vector<std::string> v = { "xyzzy", "plugh", "abracadabra" }; std::vector<std::string> v({ "xyzzy", "plugh", "abracadabra" }); std::vector<std::string> v{ "xyzzy", "plugh", "abracadabra" };  

When I try the following in Visual Studio 2012 I get the compilation error C2552: 'vecs' : non-aggregates cannot be initialized with initializer list

Here is my code:

#include <vector>  using namespace std;  int main() {     vector<string> vecs = {"h", "g", "e"}; } 

Does VS2012 not support initializer lists or am I just misunderstanding something?

Thanks!

like image 854
Polaris878 Avatar asked Sep 29 '12 16:09

Polaris878


Video Answer


1 Answers

Visual Studio 2012 does not support initializer lists.

Well, it didn't until the November 2012 CTP. Now it does, at least in an alpha state. Granted, this code still won't work in it because they're still putting initializer lists into the standard library itself.

like image 185
Nicol Bolas Avatar answered Nov 09 '22 12:11

Nicol Bolas