I'm trying to use an initialization-list to pass a list of keywords to a tokenizer to register. But it does not work in Visual Studio 2013. It works in gcc at ideone.com. Is there any way to use this or a similar syntax in VS?
struct Keyword
{
const char* name;
int id;
};
void AddKeywords(int group, std::initializer_list<Keyword>& lis) {}
// usage
AddKeywords(ITEM_TYPE, {
{ "weapon", IT_WEAPON },
{ "armor", IT_ARMOR }
});
Full error:
item.cpp(810): error C2664: 'void AddKeywords(int,std::initializer_list<Keyword> &)' : cannot convert argument 2 from 'initializer-list' to 'std::initializer_list<Keyword> &'