On Wednesday, March 8, 2017 at 11:11:27 AM UTC-8, Roman Orlov wrote:
[TLDR: folding over arbitrary binary functions]
Agreed that that might look simpler (and you could add a code comment with that syntax if you think it'd help the reader); but I don't see how you expect the compiler to figure out what you mean by that syntax, unambiguously. For example, what is
return (... std::max (Args));
return (... std::max<int> Args);
return (... func_ptr Args);
return (... (*func_ptr) Args);
return (... func_ptr*Args);
return (... (*Args) Args);
Any time you take a piece of the grammar that currently accepts a closed set of operators and propose changing it to accept an open set of expressions, that's a red flag; or at least an indication that you need to think really hard about whether there might be any corner cases.
FYI, Barry Revzin's
P0573R0 (which I am generally against) mentions (but does not propose) the syntax
[]std::max as a shortcut way of writing
[](auto&&... args) -> decltype(auto) { return std::max(args...); }. If we had that, not only would the two alternatives presented above get a lot shorter, but you wouldn't have to worry quite so much about the fact that the identifier
std::max by itself doesn't denote any particular
entity (but rather just an overload set of a bunch of otherwise unrelated entities). You could design your syntax to work cleanly with
[]foo by design.
my $.02,
Arthur