Why does const_iterator
not provide a const_iterator::base()
function, to obtain corresponding non-const iterator
like reverse_iterator
does?
Considering following pseudocode (say, geometric algorithm):
std::container< point > universe;
auto it = std::cbegin(universe);
std::list< decltype(it) > interesting_subset = sieve(it, std::cend(universe));
auto structure = algorithm(interesting_subset);
where universe
is all the input points. After sieve()
-ing the interesting_subset
contains iterators to subset of universe
's members. Following algorithm()
constructs a resulting structure
from interesting_subset
, which consists of references (iterators) to members of the universe
.
At the end, I want to change the point
s, containing into resulting structure
(say, shift them). But equally I want to protect them from modyfining during algorithm
action, and therefore I used std::cbegin
/std::cend
as opposite to std::begin
/std::end
. Finally I have only const_iterator
references to source point
s.
This is a very use case for iterator std::container< T >::const_iterator::base() const
member function I want to be present into STL containers.