SourcePro® C++ API Reference Guide

Product Documentation:
   SourcePro C++
Documentation Home
List of all members | Public Member Functions
RWTFunctor< R(As...)> Class Template Reference

A generic function object. More...

#include <rw/functor/RWTFunctor.h>

Public Member Functions

 RWTFunctor ()
 
 RWTFunctor (RWStaticCtor)
 
 RWTFunctor (const RWTFunctor< R(As...)> &other)
 
template<typename C >
 RWTFunctor (C callable)
 
operator() (As &&...a) const
 
RWTFunctor< R(As...)> & operator= (const RWTFunctor< R(As...)> &other)
 
template<typename C >
RWTFunctor< R(As...)> & operator= (C callable)
 

Detailed Description

template<typename R, typename As...>
class RWTFunctor< R(As...)>

RWTFunctor represents a generic function object that can be called with As... parameters and returns R.

Note
RWTFunctor supports calling functions with between 0 and 10 parameters, inclusive.
Example
#include <rw/functor/RWTFunctor.h>
void foo(int x) {
std::cout << "x is " << x << std::endl;
}
int main() {
// Associate the functor with the global function 'foo'
RWTFunctor<void(int)> functor = foo;
// Invoke the functor.
functor(42);
return 0;
}

Constructor & Destructor Documentation

template<typename R , typename As... >
RWTFunctor< R(As...)>::RWTFunctor ( )

Constructs an invalid function object. Self will need to be associated with a function or function object before it can be invoked.

template<typename R , typename As... >
RWTFunctor< R(As...)>::RWTFunctor ( RWStaticCtor  )

Constructs an invalid function object. This constructor assumes the object is constructed with static storage duration and does not explicitly initialize any of its members.

template<typename R , typename As... >
RWTFunctor< R(As...)>::RWTFunctor ( const RWTFunctor< R(As...)> &  other)

Copy constructor. Binds self to the functor body instance of other.

template<typename R , typename As... >
template<typename C >
RWTFunctor< R(As...)>::RWTFunctor ( callable)

Constructs a function object associated with callable. When operator() is invoked, callable will be called.

Member Function Documentation

template<typename R , typename As... >
R RWTFunctor< R(As...)>::operator() ( As &&...  a) const

Invokes the callable associated with self, passing parameters a and returning the result. If the underlying callable has not been set, throws RWTHRInvalidPointer.

template<typename R , typename As... >
RWTFunctor<R(As...)>& RWTFunctor< R(As...)>::operator= ( const RWTFunctor< R(As...)> &  other)

Assignment operator. Binds self to the functor body instance of other.

template<typename R , typename As... >
template<typename C >
RWTFunctor<R(As...)>& RWTFunctor< R(As...)>::operator= ( callable)

Assignment operator. When operator() is invoked, callable will be called.

Copyright © 2016 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.
Provide feedback to Rogue Wave about its documentation.