c++ - Can a raw pointer be passed to a template function expecting an iterator? -


Can raw pointers be sent to template function rather than tutorials? Am I correct in thinking that an Iterator is just a class that overrides indicator-related operators (such as, ++, etc.), or does the itater expose any additional interfaces that do not give the indicator? To keep it in another way, do indicators show "fast"?

Example:

I want to use the boost :: algorithm :: knuth_morris_pratt_search ().

My corpus (the string to be searched) and patterns (seen in the string) are just bytes in memory - I have an initial address indicator, and for length arguments in bytes, suppose That's this C-style string.

According to the documentation, for the knuth_morris_pratt_search function, both of us will have to start and end iterators in the corpus and patterns.

The function I want to use:

  template & lt; Typename patIter, typename corpusIter & gt; CorpusIter knuth_morris_pratt_search (corpusIter corpus_first, corpusIter corpus_last, patIter pat_first, patIter pat_last);   

Can I do this?

  // Assume that it has been started: four * c; Int cLength; Four * p; Int pLength; Four * result = knuth_morris_pratt_search & lt; Char *, char * & gt; (C, c + cLength, p, p + pLength);    

Am I thinking that an iterator is just a square override Indicator-related operator (like *, ++, etc.),

You are right; Indicators of data stored in the array correspond to the requirements of random access grammars , i.e. "complete" iterator type, so that you can use them in any standard library algorithm.

I is not a standard in hand for full reference to the random access iterator, but for example see; Also, it is a good diagram, whose various "iterators."

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -