I frequently find myself using std algorithms that depend on a begin iterator and an end iterator. Why doesn't the standard include overloads that take the container as the argument (rather than the iterators). Is there a technical reason for not including something like this in the standard?
template <typename ContainerT, typename ValueT>
typename ContainerT::iterator find(ContainerT& container, const ValueT& value)
{
return std::find(begin(container), end(container), value);
}
This is very convenient when searching whole vectors. I realize the explicit iterator version is still needed in case you don't want to iterate over the entire container.
std::vector<std::string> v;
v.push_back("foo");
v.push_back("bar");
std::find(v.begin(), v.end(), "bar");
find(v, "bar"); // much nicer! :)