The deprecation of std::iterator
is purely deprecating it use as a base class.
Using begin()
and end()
and iterators in general isn't affected by this at all.
Basically, all this is saying is that when you define an iterator, you should have something like:
template <class T /* ... */>
class my_iterator {
// the following names are what `std::iterator` defines for you:
using iterator_category = std::forward_iterator_tag;
using value_type = T;
using reference = T&;
using pointer = T*;
using difference_type = std::ptrdiff_t;
// ...
};
...and not:
template <class T /* .. */>
class my_iterator : public std::iterator<std::forward_iterator_tag, T> {
// ...
};
It also means the iterators in the standard library are intended to be done pretty much the same way (which they mostly have been, but depending on how you read it, there's an argument that older versions of the standard at least implied that they should be implemented by inheriting from std::iterator
as well).
Since you mention begin()
and end()
, I suppose it's worth adding an unrelated point: it is generally better to use std::begin()
and std::end()
rather than the member functions of various collection classes. By doing this, your code can then work with built-in arrays, rather than just classes that define begin()
and end()
as member functions. But this is entirely unrelated to std::iterator
being deprecated.