libbobcat1-dev_2.21.00-x.tar.gz Configurable Function Wrapper
2005-2012
NAME
FnWrap - Generic configurable context function wrapper class
SYNOPSIS
#include <bobcat/fnwrap>
DESCRIPTION
The FBB::FnWrap class traditionally contains two static members:
unary and binary. These functions are still available, but since
Bobcat version 2.15.00 they have identical implementations and are in fact
superseded by the new free function FBB::context (see below). All three
functions return the appropriate (unary or binary) functor that is ordinarily
called from generic algorithms of the standard template library, expecting a
unary or binary functor or predicate.
In this description there's no further reference to
FnWrap::unary and FnWrap::binary. Instead, FBB::context is
referred to, usually as just context. Instead of context the functions
FnWrap::unary or FnWrap::binary could be used as
well. FnWrap::unary and FnWrap::binary will continue to be available
in future versions of Bobcat.
The context function expects the name of a (static or free)
function that is called by the functor's function operator. The
arguments received by the functor's function operator are forwarded to this
static or free function.
Any additional arguments that are passed to context are forwarded to the
function called by the functor's function operator. This allows users of
FnWrap to pass a local context to the function that is indirectly
called by a generic algorithm.
The number and types of arguments are determined by the parameter list of the
function specified as first argument of context. If that function, in
addition to parameters matching the types of the arguments provided by the
generic algorithm also defines, e.g., an int and a std::string &
parameter, then context must be called with arguments being, respectively,
the address of the function to call, an int argument and a std::stringlvalue.
The type of the return value of the function that is passed to context
also becomes the return type of the functor's function call operator. So if
the generic algorithm expects a predicate function the function called by the
functor's function call operator should return a bool value.
The called function must be a static member or free function. Using a static
member or free function has several advantages over calling a non-static
class member function:
No object for which the member function will be called is required;
There is no introduced uncertainty about the const-ness of the
callled function, as static member functions and free functions do not support
const modifiers;
The called function can be a static member function of the class
using the generic algorithm to which the FnWrap object is passed. By
specifying the calling object as one of the arguments of context, the
called function will receive this object as well and may directly access the
calling object's members;
The passed function can be a static member function of the class
whose objects are passed to the function via the generic template function's
iterator parameters. In that case the function may directly access the passed
object's members.
Since no object is involved in calling the static function, no
ambiguity can arise as to whether an object reference or an object pointer
should be used in calling the function: static (member) functions may be
called without using objects.
NAMESPACE
FBB
All constructors, members, operators and manipulators, mentioned in this
man-page, are defined in the namespace FBB.
INHERITS FROM
-
FREE FUNCTION
Functor context(Function [, Arguments]):
This function is defined in the namespace FBB. Functor represents the (unary or binary) functor that can be used
by generic algorithms; Function is the name of a static member or free function that is
called from the Functor's function operator. The type of its first
argument (or first two arguments if a binary functor is used) must match the
type(s) of the argument(s) received by the functor's function call
operator. Any additional parameters it may define must match, in types and
number, the additional arguments that are passed to
context. Function's return type becomes the return type of
Functor's function call operator. If a value is returned by Function
that value will be returned by Functor's function call operator.
STATIC MEMBERS
Functor unary(Function [, Arguments]):
See FBB::context's description.
Functor binary(Function [, Arguments]):
See FBB::context's description.
TYPEDEFS
The functors defines types, that may be required by generic algorithms:
first_argument_type: , a synonym for the basic type of the argument
received by the unary functor's function call operator and of the first
argument received by the binary functor's function call operator. E.g., if
the actual type is std::string const * then argument_type will
be std::string;
second_argument_type: , a synonym for the basic type of the second
argument received by the binary functor's function call operator.
result_type: , a synonym for the basic type of the return type of the
functor's function call operator.