#include
struct foo {
int i;
int j;
int k;
};
int main() {
std::vector v(1);
v[0] = {0, 0, 0};
return 0;
}
Pre C++11 (and possibly C99) you can only initialize a POD at creation, not at arbitrary runtime points, which is what you're attempting here (assignment from an initializer list).
You can make a null_foo though:
int main()
{
const foo null_foo = {0, 0, 0};
std::vector<foo> v(1);
v[0] = null_foo;
return 0;
}
Brace-initialization for aggregates is only valid during declaration-initialization:
Foo a = { 1, 2, 3 };
It is not a way to generate temporaries midway: .some_function(true, {1,2,3}, 'c')
C++11 adds uniform initialization in which you can indeed write f(Foo{1,2,3});
.