In book C++ Core Guidelines Explained: Best Practices for Modern C++ there is a quote:
There is a proverb in modern C++: “When you use explicit loops, you don’t know the algorithms of the STL.”
I am writing a program at the moment, which uses an explicit for loop, that changes an object pointed to by a variable in each iteration, until it points to nullptr.
for(auto object = get_object(arg);object != nullptr;object = get_object_next(arg)) {
if (condition) {
vector_of_objects.push_back(object);
}
}
What STL function would be better suited for this than an explicit for loop?