FBB::FnWrap2 - STL binary argument wrapper template class
SYNOPSIS
#include <bobcat/fnwrap2>
DESCRIPTION
The FBB::FnWrap2 class is a configurable binary argument wrapper
template class. Its primary use is in combination with the generic algorithms
of the standard template libray.
The callled function itself may be specified as one of the constructor's
arguments. It must be a (static member) function. Using a (static member)
function has various advantages, especially with the FnWrap?c classes to
which a local context can be passed:
There is no introduced uncertainty about the const-ness of the
callled function, as static member functions do not support
a const modifier;
The passed function can also be a free (global) function to which a
local context is passed;
The passed function can be a static member function of the class
using the generic algorithm to which the FBB::FnWrap2 object is passed. By
passing the calling object in the function's local context, the function 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.
The FBB::FnWrap2 template class has the following template parameters:
Type1: the type of the first argument passed to FBB::FnWrap2's
operator()() function. Specify the type as the type of the first parameter
of the function whose address is passed to the constructor (i.e., specify a
plain value or a (const) pointer or reference).
Type2: the type of the second argument passed to FBB::FnWrap2's
operator()() function. Specify the type as the type of the second parameter
of the function whose address is passed to the constructor (i.e., specify a
plain value or a (const) pointer or reference).
ReturnType: the ReturnType is by default defined as void. By
specifying another type, the FBB::FnWrap2 object's operator()()
function will return the called function's return value as a value of the
specified type. E.g, by specifying a boolReturnType, the
FBB::FnWrap2 object may be used as a Unary Predicate. Alternatively,
pointers or references may be specified as return values.
This constructor expects one argument: the address of a function to
call from within its operator()() member. The function receives
FBB::FnWrap2::operator()()'s arguments as its arguments. When
using (STL) generic algorithms, the template parameter types Type1
and Type2 are the types to which iterators eventually point.
OVERLOADED OPERATOR
In normal situations the following member function will call the function
that is passed to FBB::FnWrap2's constructor. See the example below.
ReturnType operator()(Type1 param, Type2 param) const:
This function is called by the generic algorithms, receiving the
dereferenced iterators that are managed by generic algorithms as its
arguments (e.g., the iterator points to modifiable Type1 and Type2
objects).
TYPEDEFS
The class defines three types, which are used by generic algorithms:
first_argument_type: , a synonym for the basic type specified with the
Type1 template parameter. E.g., if Type1 is specified as
std::string const * then first_argument_type will be std::string;
second_argument_type: , a synonym for the basic type specified with the
Type2 template parameter.
result_type: , a synonym for the basic type specified with the
ReturnType template parameter.