Lambda< L, R, A > Class Template Referenceabstract

#include <Pt/Lambda.h>

Adapts a lambda or function object as a callable. More...

Inherits Callable< R, A... >.

Public Member Functions

template<typename T >
 Lambda (T &&lambda)
 Constructs from a lambda or function object.
 
virtual Callableclone () const=0
 Returns a copy of this instance. More...
 
virtual R call (As... args) const=0
 Calls the callable entity and returns its result. More...
 
operator() (As... args) const
 Same as call().
 

Related Functions

ConstMethod< R, ClassT, As... > callable (ClassT &object, R(BaseT::*method)(As...) const)
 Returns a ConstMethod object for the given object/method pair.
 
Function< R, As... > callable (R(*function)(As...))
 Returns a Function wrapper for the given free/static function.
 
Method< R, ClassT, As... > callable (ClassT &object, R(BaseT::*method)(As...))
 Returns a Method object for the given object/method pair.
 

Detailed Description

template<typename L, typename R, typename... A>
class Pt::Lambda< L, R, A >

The callable is stored by value and must therefore be copyable. For a non-generic lambda, the factory derives the Callable interface from operator(). Generic lambdas require an explicitly supplied signature.

Member Function Documentation

◆ clone()

virtual Callable* clone
pure virtualinherited

A copy of the instance is created with new is returned. Ownership is transfered to the caller, who has to delete it.

◆ call()

virtual R call ( As...  args) const
pure virtualinherited

This is the primary non-virtual entry point used by Delegate and other callers that need the return value. All derived classes must implement this.

◆ invoke()

virtual void invoke ( As...  args) const
pure virtualinherited

The passed arguments must match the template parameters.

Implements Invokable< As... >.