foreach

FBB::for_each(3bobcat)          Unary FnWrapper         FBB::for_each(3bobcat)



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:

       o      Iter represents an iterator type;

       o      Function represents a pointer to a classless or static class
              member function or to a function object;

       o      Class represents a class type;

       o      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.

       o      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.

       o      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.

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

           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
       o      bobcat_2.20.01-x.dsc: detached signature;

       o      bobcat_2.20.01-x.tar.gz: source archive;

       o      bobcat_2.20.01-x_i386.changes: change log;

       o      libbobcat1_2.20.01-x_*.deb: debian package holding the
              libraries;

       o      libbobcat1-dev_2.20.01-x_*.deb: debian package holding the
              libraries, headers and manual pages;

       o      http://sourceforge.net/projects/bobcat: public archive location;


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).

libbobcat1-dev_2.20.01-x.tar.gz    2005-2011            FBB::for_each(3bobcat)