Concepts
Definitions
Notation
F
A type that is a model of Finder
Fmt
A type that is a model of Formatter
Iter
Iterator Type
f
Object of type F
fmt
Object of type Fmt
i,j
Objects of type Iter
Finder Concept
Finder is a functor which searches for an arbitrary part of a container.
The result of the search is given as an iterator_range
delimiting the selected part.
Valid Expressions
Expression
Return Type
Effects
f(i,j)
Convertible to iterator_range<Iter>
Perform the search on the interval [i,j) and returns the result of the search
Various algorithms need to perform a search in a container and a Finder is a generalization of such
search operations that allows algorithms to abstract from searching. For instance, generic replace
algorithms can replace any part of the input, and the Finder is used to select the desired one.
Note, that it is only required that the finder works with a particular iterator type. However,
a Finder operation can be defined as a template, allowing the Finder to work with any iterator.
Examples
Finder implemented as a class. This Finder always returns the whole input as a match. operator()
is templated, so that the finder can be used on any iterator type.
struct simple_finder
{
template<typename ForwardIteratorT>
boost::iterator_range<ForwardIterator> operator()(
ForwardIteratorT Begin,
ForwardIteratorT End )
{
return boost::make_range( Begin, End );
}
};
Function Finder. Finder can be any function object. That is, any ordinary function with the
required signature can be used as well. However, such a function can be used only for
a specific iterator type.
boost::iterator_range<std::string> simple_finder(
std::string::const_iterator Begin,
std::string::const_iterator End )
{
return boost::make_range( Begin, End );
}