| Technical Specification | ||||
| Filesystem library(filesystem TS) | ||||
| Library fundamentals(library fundamentals TS) | ||||
| Library fundamentals 2(library fundamentals TS v2) | ||||
| Library fundamentals 3(library fundamentals TS v3) | ||||
| Extensions for parallelism(parallelism TS) | ||||
| Extensions for parallelism 2(parallelism TS v2) | ||||
| Extensions for concurrency(concurrency TS) | ||||
| Extensions for concurrency 2(concurrency TS v2) | ||||
| Concepts(concepts TS) | ||||
| Ranges(ranges TS) | ||||
| Reflection(reflection TS) | ||||
| Mathematical special functions(special functions TR) | ||||
| Experimental Non-TS | ||||
| Pattern Matching | ||||
| Linear Algebra | ||||
| std::execution | ||||
| Contracts | ||||
| 2D Graphics |
experimental::default_searcherexperimental::make_default_searcher | ||||
| Type-erased and polymorphic allocators | ||||
| Variable templates for type traits |
Defined in header <experimental/functional> | ||
template<class ForwardIterator1,class BinaryPredicate=std::equal_to<>> class default_searcher; | (library fundamentals TS) | |
A class suitable for use withstd::experimental::search that delegates the search operation to the standard library'sstd::search.
default_searcher isCopyConstructible andCopyAssignable.
Contents |
default_searcher( ForwardIterator pat_first, ForwardIterator pat_last, | ||
Constructs adefault_searcher by storing copies ofpat_first,pat_last, andpred.
| pat_first, pat_last | - | a pair of iterators designating the string to be searched for |
| pred | - | a callable object used to determine equality |
Any exceptions thrown by the copy constructors ofBinaryPredicate orForwardIterator.
template<class ForwardIterator2> ForwardIterator2 operator()( ForwardIterator2 first, ForwardIterator2 last)const; | (until C++17) | |
template<class ForwardIterator2> std::pair<ForwardIterator2, ForwardIterator2> | (since C++17) | |
The member function called bystd::experimental::search to perform a search with this searcher.
Equivalent tostd::search(first, last, pat_first, pat_last, pred);. | (until C++17) |
Returns a pair of iterators | (until C++17) |
| first, last | - | a pair of iterators designating the string to be examined |
Iterator to the first position in | (until C++17) |
A pair of iterators to the first and one past last positions in | (since C++17) |
template<class ForwardIterator,class BinaryPredicate=std::equal_to<>> default_searcher<ForwardIterator, BinaryPredicate> make_default_searcher( | (library fundamentals TS) | |
Helper function that constructs astd::experimental::default_searcher using template argument deduction. Equivalent toreturn default_searcher<ForwardIterator, BinaryPredicate>(pat_first, pat_last, pred);
| pat_first, pat_last | - | a pair of iterators designating the string to be searched for |
| pred | - | a callable object used to determine equality |
Adefault_searcher constructed with the argumentspat_first,pat_last,pred.
#include <experimental/algorithm>#include <experimental/functional>#include <iostream>#include <string> int main(){std::string in="Lorem ipsum dolor sit amet, consectetur adipiscing elit,"" sed do eiusmod tempor incididunt ut labore et dolore magna aliqua";std::string needle="pisci";auto it=std::experimental::search(in.begin(), in.end(), std::experimental::make_default_searcher( needle.begin(), needle.end()));if(it!= in.end())std::cout<<"The string "<< needle<<" found at offset "<< it- in.begin()<<'\n';elsestd::cout<<"The string "<< needle<<" not found\n";}
Output:
The string pisci found at offset 43
| searches for the first occurrence of a range of elements (function template)[edit] |