SourcePro® API Reference Guide

 
Classes | Modules | Enumerations | Functions

Module Description

The Functor package supplies interfaces for invocation that are independent of the actual functions. You can combine the functor classes with others in the Threads Module to transform your existing single-threaded code into multithreaded code.

For complete information about the Functor package, see the Threads Module User's Guide.

Classes

class  RWFunctor0
 Deprecated. Represents the group of functors that are invoked without any arguments and whose invocation returns no value. More...
 
class  RWFunctor0Imp
 Deprecated. Abstract base class for functor body classes that are invoked with no caller arguments and return no value. More...
 
class  RWTFunctor1< S1 >
 Deprecated. A functor that is invoked with one argument, and whose invocation returns no value. More...
 
class  RWTFunctor1Imp< S1 >
 Deprecated. Abstract base class for the family of functor bodies that are invoked with one argument and return no value. More...
 
class  RWTFunctor2< S1, S2 >
 Deprecated. A functor that is invoked with two arguments, and whose invocation returns no value. More...
 
class  RWTFunctor2Imp< S1, S2 >
 Deprecated. Abstract base class for the family of functor bodies that are invoked with two caller arguments and whose invocation returns no value. More...
 
class  RWTFunctor< R(As...)>
 A generic function object. More...
 
class  RWTFunctorR0< SR >
 Deprecated. A functor that is invoked without any arguments and whose invocation returns a value. More...
 
class  RWTFunctorR0Imp< SR >
 Deprecated. Abstract base class for the family of functor bodies that take no caller arguments at invocation time and return a value. More...
 
class  RWTFunctorR1< SR, S1 >
 Deprecated. Represents the group of functors that are invoked with one argument, and whose invocation returns a value. More...
 
class  RWTFunctorR1Imp< SR, S1 >
 Deprecated. Abstract base class for the family of functor bodies that are invoked with one caller argument and return a value. More...
 
class  RWTFunctorR2< SR, S1, S2 >
 Deprecated. Represents the group of functors that are invoked with two arguments, and whose invocation returns a value. More...
 
class  RWTFunctorR2Imp< SR, S1, S2 >
 Deprecated. Abstract base class for the family of functor bodies that are invoked with two arguments and return a value. More...
 

Modules

 rwtMakeFunctor0 Macros and Functions
 
 rwtMakeFunctor1 Macros and Functions
 
 rwtMakeFunctor2 Macros and Functions
 
 rwtMakeFunctorR0 Macros and Functions
 
 rwtMakeFunctorR1 Macros and Functions
 
 rwtMakeFunctorR2 Macros and Functions
 
 Functor List
 
 Functor Map
 

Enumerations

enum  RWCallbackScope { RW_CALL_ONCE, RW_CALL_REPEATEDLY }
 

Functions

template<typename C , typename... As>
unspecified_type rwBind (C &&c, As &&...args)
 Binds a callable and arguments into a callable object. More...
 
template<typename R , typename C , typename... As>
unspecified_type rwBind< R > (C &&c, As &&...args)
 Binds a callable and arguments into a callable object that returns R. More...
 

Enumeration Type Documentation

Header File
1 #include <rw/functor/RWCallbackScope.h>

Used when adding a callback functor to a callback list, to define how many times the functor can be invoked before being automatically removed from the list.

Enumerator
RW_CALL_ONCE 

Elements added to the list with this value will be removed from the list after their first invocation.

RW_CALL_REPEATEDLY 

Elements added to the list with this value will remain in the list until explicitly removed.

Function Documentation

template<typename C , typename... As>
unspecified_type rwBind ( C &&  c,
As &&...  args 
)

Constructs and returns a callable object of an unspecified type that invokes c, passing arguments args, and returns the result.

Assuming a bind invocation of the form rwBind(f, t1, t2, ..., tN), the callable will be invoked as follows:

  • If f is a pointer to a member function of type T, and t1 is either an object of type T, a reference to an object of type T, or a reference to an object of a type derived from T:
    1 (t1.*f)(t2, ..., tN)
  • If f is a pointer to a member function of type T and t1 is not one of the types described above:
    1 ((*t1).*f)(t2, ..., tN)
  • Otherwise:
    1 f(t1, t2, ..., tN)

Arguments to rwBind can be specified as placeholder values (rw1, rw2, ..., rw10), allowing the arguments to be provided when the returned callable object is invoked.

Example
1 int add(int x, int y) {
2  return x + y;
3 }
4 
5 // Bind the function. The first parameter will be provided when f is
6 // invoked, the second parameter is specified when the function is bound.
7 RWTFunctor<int(int)> f = rwBind(add, rw1, 5);
8 
9 // When f is invoked, the first parameter to add must be specified
10 int z = f(10); // returns 15
Note
This function allows specifying a maximum of 10 arguments.
template<typename R , typename C , typename... As>
unspecified_type rwBind< R > ( C &&  c,
As &&...  args 
)

Constructs and returns a callable object of an unspecified type that invokes c, passing arguments args, and returns the result as type R.

Assuming a bind invocation of the form rwBind<R>(f, t1, t2, ..., tN), the callable will be invoked as follows:

  • If f is a pointer to a member function of type T, and t1 is either an object of type T, a reference to an object of type T, or a reference to an object of a type derived from T:
    1 (t1.*f)(t2, ..., tN)
  • If f is a pointer to a member function of type T and t1 is not one of the types described above:
    1 ((*t1).*f)(t2, ..., tN)
  • Otherwise:
    1 f(t1, t2, ..., tN)

Arguments to rwBind can be specified as placeholder values (rw1, rw2, ..., rw10), allowing the arguments to be provided when the returned callable object is invoked.

Example
1 int add(int x, int y) {
2  return x + y;
3 }
4 
5 // Bind the function. The first parameter will be provided when f is
6 // invoked, the second parameter is specified when the function is bound.
7 RWTFunctor<long(int)> f = rwBind<long>(add, rw1, 5);
8 
9 // When f is invoked, the first parameter to add must be specified
10 long z = f(10); // returns 15 as a long
Note
This function allows specifying a maximum of 10 arguments.

Copyright © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.