FBB::for_each

FBB::for_each

libbobcat1-dev_2.02.03-x.tar.gz

2005-2009


FBB::for_each(3bobcat)

FBB::for_each(3bobcat)

libbobcat1-dev_2.02.03-x.tar.gz Unary FnWrapper

2005-2009

NAME

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: 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:

    inline void CGIFSA::setEscape(size_t idx)
    {
        d_escape[idx] = d_setEscape;
    }
        
To set a series of d_escape elements to d_setEscape a member function of the class CGIFSA may use the following code (with size_t begin, end):

    if (begin <= end)
        for_each(begin, end + 1, this, &CGIFSA::setEscape);
        

FILES

bobcat/foreach - defines the template functions

SEE ALSO

bobcat(7), fnwrap1(3bobcat), fnwrap1c(3bobcat), , fnwrap2(3bobcat), fnwrap2c(3bobcat), repeat(3bobcat)

BUGS

Note that the for_each algorithms iterate until begin equals end; hence the test for begin <= end in the above example.

DISTRIBUTION FILES

BOBCAT

Bobcat is an acronym of `Brokken's Own Base Classes And Templates'.

COPYRIGHT

This is free software, distributed under the terms of the GNU General Public License (GPL).

AUTHOR

Frank B. Brokken (f.b.brokken@rug.nl).