سؤال

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