C++11 - Initializer list of the aggregate does not work
C++ Gurus
2
Posts
2
Posters
3.1k
Views
1
Watching
-
wrote on 29 Jul 2013, 13:39 last edited by
Hello guys, I have a structure and test function:
@
struct Structure
{
QString s;
QString a;
};
void testFunc(std::initializer_list<Structure> list)
{
// ...
}
@
When I call it:
@
testFunc({"a", "b"});
@MinGW yells:
@
error: could not convert '{"a", "b"}' from '<brace-enclosed initializer list>' to 'std::initializer_list<Structure>'.
@What am I missing?
-
wrote on 4 Aug 2013, 13:31 last edited by
Can't say now, is this illegal in C++11 or just gcc flaw, but it certainly wants another pair of braces enclosing the first one, since it considers {"a", "b"} a single Structure literal, not the whole list.
1/2