3 ms·
You are right in the observation that it will save some lines of code to be /written/. Whether or not that's an essential improvement for the writers of code, I
by choeger 6y ago
You are right in the observation that it will save some lines of code to be /written/. Whether or not that's an essential improvement for the writers of code, I don't know (one must weigh the cost of knowing the feature/pattern in the first place).
But this perspective is essentially my grievance. C++ turns more and more into an exercise of programming the compiler. usability for people that want to use code is ever more deteriorating. There are more aspects like this in the language, for instance the fact that not even the std library can write out the return types or argument types of many functions. Or the hoops one has to jump through to deconstruct a std::variant (no one dared to add a proper sum type, but it is ok to implement one using the template interpreter).
- gpderetta 6y agoWell, I'm not completely disagreeing with you, but by experience, less line of code often translates in simpler to understand code in C++ if the removed code is just boilerplate (i.e. you are not just golfing). Concepts do help with the return type issue, at least now you can declare that your inferred return type conforms to some interface; for example: auto iterator take_n(auto range&& r, size_t n) {...} take_n is very generic and can return any type. But at least with concepts you can declare that it will look like an iterator. (in practice the result type depends on the range type and take_n declaration will show that). One problem with C++ is that the barrier for adding stuff to the standard library is much lower than adding it to the language. So for example we got std::bind well before we got lambdas; same thing will happen with variants (already in the library), proper union types and patter matching (there are proposals to add both the language).