3 ms·
It's more of an issue with things like std::transform or std::copy_if. Ergonomically, it's nice if these kinds of functions either allocate and return a new con
by elbows 6y ago
It's more of an issue with things like std::transform or std::copy_if. Ergonomically, it's nice if these kinds of functions either allocate and return a new container, or return an iterator that yields the elements of the result.
But the C++ versions of these take the result location as an argument. It makes chaining them together a hassle because you have to create all the intermediate containers explicitly.
I think there are good reasons for the STL to work this way, but it can make programming in a functional style pretty inconvenient compared to a lot of other languages.
- leni536 6y agoRanges will help with some of the composability issues of standard library algorithms. [1] https://en.cppreference.com/w/cpp/ranges https://en.cppreference.com/w/cpp/ranges