Is it possible to pass raw pointers to template functions waiting for iterators? Do I think correctly that an iterator is just a class that overrides the operators associated with the pointer (for example, *, ++, etc.), or do the iterators reveal some additional interface that the pointers do not have? In other words, are pointers "similar" to iterators?
Example:
I want to use boost::algorithm::knuth_morris_pratt_search ( here ).
My body (search string) and pattern (search string) are just bytes in memory - I have a pointer containing the start address and the length in bytes. For the sake of argument, let's say this is a c-style string.
According to the documentation, the knuth_morris_pratt_search function requires me to pass start and end iterators for both the case and the template.
The function I want to use:
template <typename patIter, typename corpusIter> corpusIter knuth_morris_pratt_search ( corpusIter corpus_first, corpusIter corpus_last, patIter pat_first, patIter pat_last );
Can I do it?
source share