In this example, function names are written down in the order they are called, so it looks much cleaner. Probably if we could have UFCS, this wouldn't be needed.
In real world these functions could be lambdas written in-line and consisting of several lines, so this order inconsistency may look really ugly.
Imagine a scenario where a several transformations have to be applied to an optional:
Currently this is done in this way, where orders in which functions are written and applied is inconsistent:
I propose adding a trivial member function
apply(F f)
tooptional
that applies f to*this
, so the code above can be written as:In this example, function names are written down in the order they are called, so it looks much cleaner. Probably if we could have UFCS, this wouldn't be needed.
In real world these functions could be lambdas written in-line and consisting of several lines, so this order inconsistency may look really ugly.