Today I wrote a small predicate to search for matching characters in a container.
But I ran into a problem: I want to use this predicate in a call to std::find_if inside the class's const method, looking in the container that is a member of this class.
But I just noticed that neither std::find nor std::find_if can work on const_iterators !
I checked some C ++ links and it seems that there is no version of std::find or std::find_if that accept / return const_iterators . I just can't understand why, because from what I saw, there is no way that these algorithms can modify the object referenced by the iterator.
This is how std::find documented in the SGI implementation:
Returns the first iterator I to the range [first, last], such that * i == value. Returns the last if no iterator exists.
source share