Definitions

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.

Table 9.14. 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.

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.

Formatter concept

Formatters are used by replace algorithms.
They are used in close combination with finders.
A formatter is a functor, which takes a result from a Finder operation and transforms it in a specific way.
The operation of the formatter can use additional information provided by a specific finder,
for example regex_formatter() uses the match information from
regex_finder() to format the result of formatter operation.

Table 9.15. Valid Expressions

Expression

Return Type

Effects

fmt(f(i,j))

A container type, accessible using container traits

Formats the result of the finder operation

Similarly to finders, formatters generalize format operations. When a finder is used to
select a part of the input, formatter takes this selection and performs some formating
on it. Algorithms can abstract from formating using a formatter.

Examples

Formatter implemented as a class. This Formatter does not perform any formating and
returns the match, repackaged. operator()
is templated, so that the Formatter can be used on any Finder type.