Is it theoretically possible to add a language feature to unpack structures into the function actual parameter lists? I mean the following.
template< typename ...Ts >
void f(Ts... values) { (std::cout << ... << values) << std::endl; }
struct S { int a; char c; double d; };
S s{1, '2', 3.0};
f([s]);
void g(int, int, int) {}
g([s]); // warning about narrowing conversion
void h(int &, int &, int &) {}
h([s]); // hard error ("cannot bind to...")
It would be handy to deal with suitable structures of unknown count of members. Because current structured bindings can't "unpack" structures of unknown number of components (like auto... [x] = s;
) due to lack of the template context, where only possible operator ...
to deal with variadic number of types/values.
What downsides can be on this way?