RWTFunctorR2 RWHandleBase
#include <rw/functor/functorR2.h>
RWTFunctorR2<SR,S1,S2> represents the group of functors that are invoked with two arguments, and whose invocation returns a value.
A function object, or a 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.
Instances of RWTFunctorR2 act as handles to functor implementations or bodies. Such implementations are created by using either the rwtMakeFunctorR2() global functions or macros. Each of these methods creates a new body instance, and returns the handle to that instance. See the example below.
Note that although an instance of this class is invoked with two arguments, the encapsulated function may have more arguments.
The additional arguments that will be passed to the encapsulated function are provided to the functor at the time of creation. They are stored within the functor object, and are retrieved at the time of invocation.
#include <rw/functor/functorR2.h> long foo(int i, short s){ return (long)i+s;} int main () { // Create a handle, and assign a new body to it. RWTFunctorR2<long,int,short> functor = rwtMakeFunctorR2( (long(*)(int,short))0, foo ); // Invoke the functor with two caller arguments. long return_value = functor(42,3); return 0; }
typedef S1 S1Type;
The type of the first caller argument.
typedef S2 S2Type;
The type of the second caller argument.
typedef SR (*CallerSignature)(S1,S2);
The signature of the functor invocation.
typedef SR SRType;
The type of the functor's return value.
RWTFunctorR2(void);
Constructs an empty, invalid, handle instance. To create a viable handle, use the rwtMakeFunctor1() global functions or macros.
RWTFunctorR2(RWStaticCtor);
Constructs a global static handle instance. Constructor will not reset any values that may have been set in invocations prior to the constructor call.
RWTFunctorR2(const RWTFunctorR2<SR,S1,S2>& second);
Copy constructor. Binds a new handle instance to the functor body instance, if any, associated with the second handle instance.
RWTFunctorR2<SR,S1,S2>& operator=(const RWTFunctorR2<SR,S1,S2>& second);
Assignment operator. Detaches this handle instance from any functor body instance it currently references, and binds it to the functor body instance, if any, associated with the second handle instance.
SR operator()(S1 s1, S2 s2) const;
Invokes the functor, calling the encapsulated function. Throws an RWTHRInvalidPointer if the handle has no associated body.
©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.