Embedded Template Library 1.0
Loading...
Searching...
No Matches
etl::delegate< TReturn(TParams...)> Class Template Referencefinal

Specialisation. More...

#include <delegate_cpp11.h>

Public Member Functions

ETL_CONSTEXPR14 delegate ()
 Default constructor.
 
ETL_CONSTEXPR14 delegate (const delegate &other)=default
 
template<typename TLambda , typename = etl::enable_if_t<etl::is_class<TLambda>::value && !etl::is_same<etl::delegate<TReturn(TParams...)>, TLambda>::value, void>>
ETL_CONSTEXPR14 delegate (TLambda &instance)
 
template<typename TLambda , typename = etl::enable_if_t<etl::is_class<TLambda>::value && !etl::is_same<etl::delegate<TReturn(TParams...)>, TLambda>::value, void>>
ETL_CONSTEXPR14 delegate (const TLambda &instance)
 
template<TReturn(*)(TParams...) Method>
ETL_CONSTEXPR14 void set ()
 Set from function (Compile time).
 
template<typename TLambda , typename = etl::enable_if_t<etl::is_class<TLambda>::value && !etl::is_same<etl::delegate<TReturn(TParams...)>, TLambda>::value, void>>
ETL_CONSTEXPR14 void set (TLambda &instance)
 Set from Lambda or Functor.
 
template<typename TLambda , typename = etl::enable_if_t<etl::is_class<TLambda>::value && !etl::is_same<etl::delegate<TReturn(TParams...)>, TLambda>::value, void>>
ETL_CONSTEXPR14 void set (const TLambda &instance)
 Set from const Lambda or Functor.
 
template<typename T , TReturn(T::*)(TParams...) Method>
ETL_CONSTEXPR14 void set (T &instance)
 Set from instance method (Run time).
 
template<typename T , TReturn(T::*)(TParams...) const Method>
ETL_CONSTEXPR14 void set (T &instance)
 Set from const instance method (Run time).
 
template<typename T , T & Instance, TReturn(T::*)(TParams...) Method>
ETL_CONSTEXPR14 void set ()
 Set from instance method (Compile time).
 
template<typename T , TReturn(T::*)(TParams...) Method, T & Instance>
ETL_CONSTEXPR14 void set ()
 
template<typename T , T const & Instance, TReturn(T::*)(TParams...) const Method>
ETL_CONSTEXPR14 void set ()
 Set from const instance method (Compile time).
 
template<typename T , TReturn(T::*)(TParams...) const Method, T const & Instance>
ETL_CONSTEXPR14 void set ()
 
ETL_CONSTEXPR14 void clear ()
 Clear the delegate.
 
TReturn operator() (TParams... args) const
 Execute the delegate.
 
template<typename TRet = TReturn>
ETL_CONSTEXPR14 etl::enable_if_t< etl::is_same< TRet, void >::value, boolcall_if (TParams... args) const
 
template<typename TRet = TReturn>
ETL_CONSTEXPR14 etl::enable_if_t<!etl::is_same< TRet, void >::value, etl::optional< TReturn > > call_if (TParams... args) const
 
template<typename TAlternative >
TReturn call_or (TAlternative alternative, TParams... args) const
 
template<TReturn(*)(TParams...) Method>
TReturn call_or (TParams... args) const
 
delegateoperator= (const delegate &rhs)=default
 Assignment.
 
template<typename TLambda , typename = etl::enable_if_t<etl::is_class<TLambda>::value && !etl::is_same<etl::delegate<TReturn(TParams...)>, TLambda>::value, void>>
ETL_CONSTEXPR14 delegateoperator= (TLambda &instance)
 Create from Lambda or Functor.
 
template<typename TLambda , typename = etl::enable_if_t<etl::is_class<TLambda>::value && !etl::is_same<etl::delegate<TReturn(TParams...)>, TLambda>::value, void>>
ETL_CONSTEXPR14 delegateoperator= (const TLambda &instance)
 Create from const Lambda or Functor.
 
ETL_CONSTEXPR14 bool operator== (const delegate &rhs) const
 Checks equality.
 
ETL_CONSTEXPR14 bool operator!= (const delegate &rhs) const
 Returns true if the delegate is valid.
 
ETL_NODISCARD ETL_CONSTEXPR14 bool is_valid () const
 Returns true if the delegate is valid.
 
ETL_CONSTEXPR14 operator bool () const
 Returns true if the delegate is valid.
 

Static Public Member Functions

template<TReturn(*)(TParams...) Method>
static ETL_NODISCARD ETL_CONSTEXPR14 delegate create ()
 Create from function (Compile time).
 
template<typename TLambda , typename = etl::enable_if_t<etl::is_class<TLambda>::value && !etl::is_same<etl::delegate<TReturn(TParams...)>, TLambda>::value, void>>
static ETL_NODISCARD ETL_CONSTEXPR14 delegate create (TLambda &instance)
 Create from Lambda or Functor.
 
template<typename TLambda , typename = etl::enable_if_t<etl::is_class<TLambda>::value && !etl::is_same<etl::delegate<TReturn(TParams...)>, TLambda>::value, void>>
static ETL_NODISCARD ETL_CONSTEXPR14 delegate create (const TLambda &instance)
 Create from const Lambda or Functor.
 
template<typename T , TReturn(T::*)(TParams...) Method>
static ETL_NODISCARD ETL_CONSTEXPR14 delegate create (T &instance)
 Create from instance method (Run time).
 
template<typename T , TReturn(T::*)(TParams...) Method>
static ETL_NODISCARD ETL_CONSTEXPR14 delegate create (T &&instance)=delete
 
template<typename T , TReturn(T::*)(TParams...) const Method>
static ETL_NODISCARD ETL_CONSTEXPR14 delegate create (const T &instance)
 Create from const instance method (Run time).
 
template<typename T , TReturn(T::*)(TParams...) const Method>
static ETL_CONSTEXPR14 delegate create (T &&instance)=delete
 Disable create from rvalue instance method (Run time).
 
template<typename T , T & Instance, TReturn(T::*)(TParams...) Method>
static ETL_NODISCARD ETL_CONSTEXPR14 delegate create ()
 Create from instance method (Compile time).
 
template<typename T , TReturn(T::*)(TParams...) Method, T & Instance>
static ETL_NODISCARD ETL_CONSTEXPR14 delegate create ()
 
template<typename T , T const & Instance, TReturn(T::*)(TParams...) const Method>
static ETL_NODISCARD ETL_CONSTEXPR14 delegate create ()
 Create from const instance method (Compile time).
 
template<typename T , TReturn(T::*)(TParams...) const Method, T const & Instance>
static ETL_NODISCARD ETL_CONSTEXPR14 delegate create ()
 
template<typename T , T & Instance>
static ETL_NODISCARD ETL_CONSTEXPR14 delegate create ()
 

Detailed Description

template<typename TReturn, typename... TParams>
class etl::delegate< TReturn(TParams...)>

Specialisation.

Member Function Documentation

◆ call_if() [1/2]

template<typename TReturn , typename... TParams>
template<typename TRet = TReturn>
ETL_CONSTEXPR14 etl::enable_if_t< etl::is_same< TRet, void >::value, bool > etl::delegate< TReturn(TParams...)>::call_if ( TParams...  args) const
inline

Execute the delegate if valid. 'void' return.

◆ call_if() [2/2]

template<typename TReturn , typename... TParams>
template<typename TRet = TReturn>
ETL_CONSTEXPR14 etl::enable_if_t<!etl::is_same< TRet, void >::value, etl::optional< TReturn > > etl::delegate< TReturn(TParams...)>::call_if ( TParams...  args) const
inline

Execute the delegate if valid. Non 'void' return.

◆ call_or() [1/2]

template<typename TReturn , typename... TParams>
template<typename TAlternative >
TReturn etl::delegate< TReturn(TParams...)>::call_or ( TAlternative  alternative,
TParams...  args 
) const
inline

Execute the delegate if valid or call alternative. Run time alternative.

◆ call_or() [2/2]

template<typename TReturn , typename... TParams>
template<TReturn(*)(TParams...) Method>
TReturn etl::delegate< TReturn(TParams...)>::call_or ( TParams...  args) const
inline

Execute the delegate if valid or call alternative. Compile time alternative.

◆ create() [1/4]

template<typename TReturn , typename... TParams>
template<typename T , TReturn(T::*)(TParams...) Method, T & Instance>
static ETL_NODISCARD ETL_CONSTEXPR14 delegate etl::delegate< TReturn(TParams...)>::create ( )
inlinestatic

Create from instance method (Compile time). New API

◆ create() [2/4]

template<typename TReturn , typename... TParams>
template<typename T , TReturn(T::*)(TParams...) const Method, T const & Instance>
static ETL_NODISCARD ETL_CONSTEXPR14 delegate etl::delegate< TReturn(TParams...)>::create ( )
inlinestatic

Create from const instance method (Compile time). New API

◆ create() [3/4]

template<typename TReturn , typename... TParams>
template<typename T , T & Instance>
static ETL_NODISCARD ETL_CONSTEXPR14 delegate etl::delegate< TReturn(TParams...)>::create ( )
inlinestatic

Create from instance function operator (Compile time). At the time of writing, GCC appears to have trouble with this.

◆ create() [4/4]

template<typename TReturn , typename... TParams>
template<typename T , TReturn(T::*)(TParams...) Method>
static ETL_NODISCARD ETL_CONSTEXPR14 delegate etl::delegate< TReturn(TParams...)>::create ( T &&  instance)
staticdelete

Create from instance method (Run time). Deleted for rvalue references.

◆ set() [1/2]

template<typename TReturn , typename... TParams>
template<typename T , TReturn(T::*)(TParams...) Method, T & Instance>
ETL_CONSTEXPR14 void etl::delegate< TReturn(TParams...)>::set ( )
inline

Set from instance method (Compile time). New API

◆ set() [2/2]

template<typename TReturn , typename... TParams>
template<typename T , TReturn(T::*)(TParams...) const Method, T const & Instance>
ETL_CONSTEXPR14 void etl::delegate< TReturn(TParams...)>::set ( )
inline

Set from const instance method (Compile time). New API


The documentation for this class was generated from the following file: