One can create an anonymous object that is initialized through constructor parameters, such as in the return statement, below.
struct S {
S(int i_, int j_) : i(i_), j(j_) { }
int i, j;
};
S f()
{
return S(52, 100);
}
int main()
{
cout << f().i << endl;
return 0;
}
However, can one similarly create an anonymous aggregate that is initialized with a brace initializer? For example, can one collapse the body of f(), below, down to a single return statement without an "s?"
struct S {
int i, j;
};
S f()
{
S s = { 52, 100 };
return s;
}
int main()
{
cout << f().i << endl;
return 0;
}