GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::default_searcher(3) C++ Standard Libary std::default_searcher(3)

std::default_searcher - std::default_searcher


Defined in header <functional>
template< class ForwardIt, class BinaryPredicate = std::equal_to<> > (since C++17)
class default_searcher;


A class suitable for use with Searcher overload of std::search that delegates the
search operation to the pre-C++17 standard library's std::search.


default_searcher is CopyConstructible and CopyAssignable.

std::default_searcher::default_searcher


default_searcher( ForwardIt pat_first,
(since C++17)
ForwardIt pat_last, (until C++20)


BinaryPredicate pred = BinaryPredicate());
constexpr default_searcher( ForwardIt pat_first,


ForwardIt pat_last, (since C++20)


BinaryPredicate pred = BinaryPredicate());


Constructs a default_searcher by storing copies of pat_first, pat_last, and pred


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 of BinaryPredicate or ForwardIt.

std::default_searcher::operator()


template< class ForwardIt2 >
(since C++17)
std::pair<ForwardIt2, ForwardIt2> (until C++20)


operator()( ForwardIt2 first, ForwardIt2 last ) const;
template< class ForwardIt2 >


constexpr std::pair<ForwardIt2, ForwardIt2> (since C++20)


operator()( ForwardIt2 first, ForwardIt2 last ) const;


The member function called by the Searcher overload of std::search to perform a
search with this searcher.


Returns a pair of iterators i, j, where i is std::search(first, last, pat_first,
pat_last, pred) and j is std::next(i, std::distance(pat_first, pat_last)) unless
std::search returned last (no match), in which case j equals last as well.


first, last - a pair of iterators designating the string to be examined


A pair of iterators to the first and one past last positions in [first, last) where
a subsequence that compares equal to [pat_first, pat_last) as defined by pred is
located, or a pair of copies of last otherwise.

// Run this code


#include <iostream>
#include <string>
#include <algorithm>
#include <functional>


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::search(in.begin(), in.end(),
std::default_searcher(
needle.begin(), needle.end()));
if(it != in.end())
std::cout << "The string " << needle << " found at offset "
<< it - in.begin() << '\n';
else
std::cout << "The string " << needle << " not found\n";
}


The string pisci found at offset 43


search searches for a range of elements
(function template)
boyer_moore_searcher Boyer-Moore search algorithm implementation
(C++17) (class template)
boyer_moore_horspool_searcher Boyer-Moore-Horspool search algorithm implementation
(C++17) (class template)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.