Why are there no STL algorithms that work on whole containers?(herbsutter.com)
herbsutter.com
Why are there no STL algorithms that work on whole containers?
http://herbsutter.com/2011/10/07/why-no-container-based-algorithms/
http://herbsutter.com/2011/10/07/why-no-container-based-algorithms/
You can't call begin() or end() on a pointer. And although you can figure out the end of a stack-allocated C array, you can't do it for a heap-based array. For example, with "x = new int[30]" and a call like "sort(x, ...)", you may know the size of "x" but the algorithm can't know. The solution is to make algorithms accept a form like "sort(x, x + 30, ...)".
Of course now, with things like std::array in the standard, there are fewer reasons to care about pointers than before.