FBB::for_each - Extensions to the STL for_each function template
SYNOPSIS
#include <bobcat/foreach>
DESCRIPTION
The FBB::for_each function templates extend the STL for_each function
template allowing its use in many often occurring situations.
The STL for_each function template requires a pair of iterators preventing
its use in situations where an action should be performed a number of times
using a plain, non-dereferenceable variable rather than an
iterator. Furthermore, the STL template requires the use of either a classless
or static class member function or a function object. In situations in which a
class member is called a number of times the STL template function cannot
easily be used.
The FBB::for_each function template was designed to allow the use of the
for_each algorithm in the abovementioned situations. It cannot be used to
pass a `local function context' to the function performing the action and it
cannot be used to call a function a number of times. In the former case the
FBB::FnWrap1c and FBB::FnWrap2c classes can be used; in the latter
case the repeat(3bobcat) function templates can be used.
All FBB::for_each template functions are defined inline,
allowing the compiler to `optimize away' the for_each function call
itself.
Since some of the FBB::for_each function templates use the same number of
parameters as the stl::for_each function templates the explicit use of the
FBB namespace will often be required in situations where both function
templates are made available to the compiler.
NAMESPACE
FBB
All constructors, members, operators and manipulators, mentioned in this
man-page, are defined in the namespace FBB.
INHERITS FROM
-
OVERLOADED FUNCTIONS
In the following description several template type parameters are
used. They are:
Iter represents an iterator type;
Function represents a pointer to a classless or static class
member function or to a function object;
Class represents a class type;
Member represents a pointer to a Class member function
expecting a (reference to a) derefenced Iter object or an argument of the
same type as the first for_each parameter.
void for_each(Iter begin, Iter end, Function &fun): fun is called end - begin times, passing begin or
*begin with begin iterating towards end to fun. If
begin and end are class- or pointer type variables *begin
is passed to fun otherwise begin is passed to fun.
void for_each(Iter begin, Iter end, Class &object, Member member): object.*member is called end - begin times, passing begin
or *begin with begin iterating towards end to
object.*member. If begin and end are class- or pointer
type variables *begin is passed to fun otherwise begin is
passed to fun.
void for_each(Iter begin, Iter end, Class *object, Member member): object->*member is called end - begin times, passing begin
or *begin with begin iterating towards end to
object->*member. If begin and end are class- or pointer
type variables *begin is passed to fun otherwise begin is
passed to fun.
Class and Member may also be defined as const objects.
EXAMPLES
Assume a class CGIFSA defines the following inline function, using the
array bool d_escape[] and the variable bool d_setEscape: