这是一个愚蠢的问题,但我有这个错误:
#include <unordered_set>
std::unordered_set<std::string> ValidValues **{**"one", "two", "three"};
错误:预期“;”出现在第一个括号。与“集合”完全相同。
重新启动Visual Studio 2010和计算机。
答案 0 :(得分:3)
这有效:
#include <string>
#include <unordered_set>
std::unordered_set<std::string> ValidValues {"one", "two", "three"};
GCC 4.4+,Clang 3.1+和MSVS2013+。
MSVS2010/2012 does not support名为list initialization的语言功能,您正在做的事情。