Recently on Codexpert, an enthusiastic and very readable reaction to two fresh standards proposals that will be considered two weeks from now at the ISO C++ meeting in Urbana-Champaign, Illinois, USA:
Extension methods in C++
by Marius Bancila
From the article:
... if
x.f(y)
andf(x,y)
were equivalent it would be very easy to write the above code like this:auto v = std::vector<int> {1,2,3,4,5,6,7,8,9}; auto s = v.where([](int e){return e % 2 == 0; }) .select([](int e){return e*e; }) .sum();Isn’t that beautiful? I think it is.
...
The N4174 paper is rather an exploration of possibilities for uniform calling syntax than a very formal proposal. There are various aspects that have to be carefully considered especially when considering how to treat
f(x, y)
. The N4165 paper makes a good case of the uniform calling syntax, explains the benefits better and argues against treatingf(x)
equivalent tox.f()
. You should go ahead and read the two papers for detailed information. However, I sincerely hope that one day this will be accepted and become a core feature of the C++ language.
Add a Comment
Comments are closed.