문제

Well this is a silly question but I have this error :

#include <unordered_set> 
std::unordered_set<std::string> ValidValues **{**"one", "two", "three"};

Error : expected a ";" appears at the first bracket. Exacty the same with a "set".

Restarted Visual Studio 2010 and the computer.

도움이 되었습니까?

해결책

This works:

#include <string>
#include <unordered_set> 
std::unordered_set<std::string> ValidValues {"one", "two", "three"};

with GCC 4.4+, Clang 3.1+, and MSVS2013+.

MSVS2010/2012 does not support the language feature called list initialization, wich is what you are doing.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top