Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Threads Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

rwtMakeFunctor2()

Module:  Threads   Package:  Functor


Global Functions and Macros

Local Index

Members

Non-Members

Header File

#include <rw/functor/functor2.h>

Description

A function object, or functor, is an object that encapsulates a call to an associated global or member function. When a functor is invoked, it calls the associated function.

The rwtMakeFunctor2() functions and macros are provided to construct functors based on the RWTFunctor2<S1,S2> class. The RWTFunctor2<S1,S2> class acts as the handle for a family of functor implementation classes based on the RWTFunctor2Imp<S1,S2> class. A functor based on RWTFunctor2<S1,S2> is invoked with two arguments and returns no value, but the implementation classes can accept functions with up to two additional arguments and any return type. The values for the additional arguments are defined when an implementation class instance is constructed, and are passed to the function each time the functor is invoked.

Each rwtMakeFunctor2() function or macro instantiates and constructs an appropriate functor implementation class instance and returns an RWTFunctor2<S1,S2> handle that is bound to that instance.

rwtMakeFunctor2() comes in two flavors. First, there is a set of overloaded global function templates. Since not all compilers are able to handle templates to the degree required by these functions, we also provide a corresponding set of macros. The template functions are slightly easier to use and you only have to remember one name. The macros are more portable but they do require more arguments; and because we cannot overload macros, each must have a unique name.

In naming the macros we have employed a convention to make the names easier to remember. Each name begins with rwtMakeFunctor2(), which will be followed by either a G if the macro is expecting a global function, or an M if it is expecting a member function. At that point the name is complete if the associated global or member function takes no additional arguments. Otherwise we add one of A1 or A2 for functions with 1 or 2 additional arguments respectively. For example, you will use macro rwtMakeFunctor2G() to create a functor that calls a global function that takes no additional arguments. The macro rwtMakeFunctor2MA2() will create a functor that calls a member function that takes two additional arguments.

Example Using Templates

Example Using Macros

Global Function Templates

The following information applies to each of the function templates in this section:

template <class S1, class S2, class DR, class D1, class D2>
RWTFunctor2<S1,S2> 
rwtMakeFunctor2(void (*invokeAs)(S1,S2), 
DR (*function)(D1,D2));
template <class S1, class S2, 
           class DR, class D1, class D2, class A1, class AA1>
RWTFunctor2<S1,S2> 
rwtMakeFunctor2(void (*invokeAs)(S1,S2),
               DR (*function)(D1,D2,A1), AA1 a1)
template <class S1, class S2, class DR, class D1, class D2, 
          class A1, class A2, class AA1, class AA2>
RWTFunctor2<S1,S2> 
rwtMakeFunctor2(void (*invokeAs)(S1,S2), 
               DR (*function)(D1,D2,A1,A2), AA1 a1, AA2 a2)
template <class S1, class S2, 
          class Callee, class DR, class D1, class D2>
RWTFunctor2<S1,S2> 
rwtMakeFunctor2(void(*invokeAs)(S1,S2), Callee& callee,
               DR (Callee::*function)(D1,D2))
template <class S1, class S2, class Callee, class DR, 
          class D1, class D2, class A1, class AA1>
RWTFunctor2<S1,S2>
rwtMakeFunctor2(void(*invokeAs)(S1,S2), Callee& callee,
               DR (Callee::*function)(D1,D2,A1), AA1 a1)
template <class S1, class S2, class Callee, 
          class DR, class D1, class D2,
          class A1, class A2, class AA1, class AA2>
RWTFunctor2<S1,S2> 
rwtMakeFunctor2(void(*invokeAs)(S1,S2), Callee& callee,
               DR (Callee::*function)(A1,A2), AA1 a1, AA2 a2)

Macros for Use With Global Functions

The macros in this section use the following naming conventions for the macro arguments:

rwtMakeFunctor2G(S1,S2,DR,function,D1,D2)
rwtMakeFunctor2GA1(S1,S2,DR,function,D1,D2,A1,a1)
rwtMakeFunctor2GA2(S1,S2,DR,function,D1,D2,A1,a1,A2,a2)

Macros for Use With Member Functions

The macros in this section use the following naming conventions for the macro arguments:

rwtMakeFunctor2M(S1,S2,Callee,callee,DR,function,D1,D2) 
rwtMakeFunctor2MA1(S1,S2,Callee,callee,DR,function,D1,D2,A1,a1) 
rwtMakeFunctor2MA2(S1,S2,Callee,callee,DR,
function,D1,D2,A1,a1,A2,a2)

See Also

RWTFunctor2<S1,S2>, RWTFunctor2Imp<S1,S2>



Previous fileTop of DocumentContentsIndex pageNext file

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.