Clarisse 5.0 SP8 SDK  5.0.5.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | List of all members
CoreFunction< R(Args...)> Class Template Reference

Simplified version of the std::function object. More...

Public Member Functions

 CoreFunction (void)
 
 ~CoreFunction ()
 Destructor.
 
 CoreFunction (const CoreFunction &other)
 Copy constructor.
 
 CoreFunction (CoreFunction &&other)
 Move constructor.
 
CoreFunctionoperator= (const CoreFunction &other)
 Copy assignment operator.
 
CoreFunctionoperator= (CoreFunction &&other)
 Move assignment operator.
 
template<typename Functor >
 CoreFunction (const Functor &functor)
 
template<typename Functor >
CoreFunctionoperator= (const Functor &functor)
 
operator() (Args...args) const
 Callbale operator.
 

Detailed Description

template<typename R, typename... Args>
class CoreFunction< R(Args...)>

Simplified version of the std::function object.

This can be used to store a lambda or any "callable" thing. It's used like std::function: ``` CoreFunction<bool (int)> function = [] (int a) { return (a % 2) == 0; }; function(3); ```

Note that like std::function, you need to be carefull with the lifetime of what you pass to it. For instance if you create a CoreFunction from a lambda, make sure that if the lambda captures stuff, you capture either by value, or that the reference captured objects won't be destoyed before the function is used.

Constructor & Destructor Documentation

template<typename R , typename... Args>
CoreFunction< R(Args...)>::CoreFunction ( void  )
inline

Default constructor. Calling a CoreFunction initialized like this is undefined behavior! (e.g. will probably crash)

template<typename R , typename... Args>
template<typename Functor >
CoreFunction< R(Args...)>::CoreFunction ( const Functor &  functor)
inline

Construct an instance from a "functor" (basically any callbale thing: a pointer to a static function, lambda, function object, etc.)

Parameters
functorThe functor. Needs to have a copy constructor and a move constructor.

Member Function Documentation

template<typename R , typename... Args>
template<typename Functor >
CoreFunction< R(Args...)> & CoreFunction< R(Args...)>::operator= ( const Functor &  functor)
inline

Assign a function object.

Parameters
functorThe function object. Can be a lambda, pointer to function, etc.