4 ms·
Unified call syntax would have allowed something like a function of the form f( list, condition ); to be called as list.f( condition ). I don't think it made i
by beached_whale 10y ago
Unified call syntax would have allowed something like a function of the form f( list, condition ); to be called as list.f( condition ). I don't think it made it into C++ 17 though. It's too bad because that would have allowed some really powerful extending of existing code. C# has this already. I hope that it makes it into C++20
https://isocpp.org/blog/2016/02/a-bit-of-background-for-the-unified-call-proposal https://isocpp.org/blog/2016/02/a-bit-of-background-for-the-...
Also, you can do stuff like
auto blah = with( list ) << sort( ) << filter( predicate );
now. It's not in the std lib but it is doable
- braveo 10y agoC# doesn't have unified call syntax, it has extension methods. You're right in that they do allow you to write a function that takes an argument and call it as if it wasn't on that argument, but it doesn't have UCS generically, just as a special case.
- beached_whale 10y agoYou are technically correct, the best kind. The ability is similar though, although I can see some fun C++ code with templates to apply it to all types. Then, if allowed, something like int i; i.print( ); could happen.