default_searcher Class
A default_searcher
is a function object type for operations that search for a sequence specified in the object's constructor. The search is done within another sequence provided to the object's function call operator. The default_searcher
invokes std::search to perform the search.
Syntax
template <class ForwardIterator, class BinaryPredicate = equal_to<>>
class default_searcher
{
default_searcher(
ForwardIterator pat_first,
ForwardIterator pat_last,
BinaryPredicate pred = BinaryPredicate());
template <class ForwardIterator2>
pair<ForwardIterator2, ForwardIterator2> operator()(
ForwardIterator2 first,
ForwardIterator2 last) const;
};
Members
Member | Description |
---|---|
Constructor | |
default_searcher | Constructs a searcher instance. |
Operators | |
operator() | Invokes the operation on the sequence. |
default_searcher constructor
Constructs a default_searcher
function object by using the sequence to search for and an equality predicate.
default_searcher( // C++17
ForwardIterator pat_first,
ForwardIterator pat_last,
BinaryPredicate pred = BinaryPredicate());
constexpr default_searcher( // C++20
ForwardIterator pat_first,
ForwardIterator pat_last,
BinaryPredicate pred = BinaryPredicate());
Parameters
pat_first
The initial element of the sequence to search for.
pat_last
The end of the sequence to search for.
pred
The optional equality comparison predicate for sequence elements. If an equality comparison type isn't specified, the default is std::equal_to
.
Remarks
Throws any exception thrown by the copy constructor of the BinaryPredicate or ForwardIterator types.
This class is new in C++17. C++20 made the constructor constexpr
.
operator()
The call operator of the function operator. Searches within the argument sequence [first, last)
for the sequence specified to the constructor.
template <class ForwardIterator2> // C++17
pair<ForwardIterator2, ForwardIterator2> operator()(
ForwardIterator2 first,
ForwardIterator2 last) const;
template <class ForwardIterator2> // C++20
constexpr pair<ForwardIterator2, ForwardIterator2> operator()(
ForwardIterator2 first,
ForwardIterator2 last) const;
Parameters
first
The initial element of the sequence to search within.
last
The end of the sequence to search within.
Remarks
Returns a pair of iterators. The initial iterator i is the effective result of:
std::search( first, last, pat_first, pat_last, pred )
.
The second iterator of the pair is last if i* is last. Otherwise, it's the effective result of:
std::next( i, std::distance( pat_first, pat_last ))
.
This class is new in C++17. C++20 made the call operator constexpr
.
See also
Feedback
https://aka.ms/ContentUserFeedback.
În curând: Pe parcursul anului 2024, vom elimina treptat Probleme legate de GitHub ca mecanism de feedback pentru conținut și îl vom înlocui cu un nou sistem de feedback. Pentru mai multe informații, consultați:Trimiteți și vizualizați feedback pentru