...

/

Using Searchers

Using Searchers

The lesson will elaborate the syntax and methods for using Searchers.

We'll cover the following...

The std::search function uses the following overload for searchers:

Press + to interact
template<class ForwardIterator, class Searcher>
ForwardIterator search(ForwardIterator first, ForwardIterator last, const Searcher& searcher );

For example:

Press + to interact
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
string testString = "Hello Super World";
string needle = "Super";
const auto it = search(begin(testString), end(testString), boyer_moore_searcher(begin(needle), end(needle)));
if (it == cend(testString))
cout << "The string " << needle << " not found\n";
return 0;
}

Each searcher initializes its state ...