SPH
Classes | Public Member Functions | List of all members
Function< TReturn(TArgs...)> Class Template Reference

Wrapper of callable objects. More...

#include <Function.h>

Public Member Functions

 Function ()=default
 
template<typename TFunctor , typename = std::enable_if_t<IsCallable<TFunctor, TArgs...>::value>>
 Function (TFunctor functor)
 Creates a function given a callable object. More...
 
 Function (const Function &other)
 
 Function (Function &&other)
 
 Function (std::nullptr_t)
 
template<typename TFunctor >
Functionoperator= (TFunctor functor)
 
Functionoperator= (const Function &other)
 
Functionoperator= (Function &&other)
 
Functionoperator= (std::nullptr_t)
 
template<typename... Ts>
TReturn operator() (Ts &&... args) const
 Calls the function, given argument list. More...
 
template<typename... Ts>
void callIfNotNull (Ts &&... args) const
 Calls the function is set, otherwise it does nothing. More...
 
INLINE operator bool () const
 

Detailed Description

template<typename TReturn, typename... TArgs>
class Function< TReturn(TArgs...)>

Wrapper of callable objects.

Function is copyable, having a pointer semantics. Copied object reference the same callable.

Definition at line 31 of file Function.h.

Constructor & Destructor Documentation

◆ Function() [1/5]

template<typename TReturn , typename... TArgs>
Function< TReturn(TArgs...)>::Function ( )
default

◆ Function() [2/5]

template<typename TReturn , typename... TArgs>
template<typename TFunctor , typename = std::enable_if_t<IsCallable<TFunctor, TArgs...>::value>>
Function< TReturn(TArgs...)>::Function ( TFunctor  functor)
inline

Creates a function given a callable object.

The functor is passed by value on purpose, we do not want to store references in the function. It also helps avoiding calling this constructor instead of copy/move constructors.

Definition at line 57 of file Function.h.

◆ Function() [3/5]

template<typename TReturn , typename... TArgs>
Function< TReturn(TArgs...)>::Function ( const Function< TReturn(TArgs...)> &  other)
inline

Definition at line 60 of file Function.h.

◆ Function() [4/5]

template<typename TReturn , typename... TArgs>
Function< TReturn(TArgs...)>::Function ( Function< TReturn(TArgs...)> &&  other)
inline

Definition at line 63 of file Function.h.

◆ Function() [5/5]

template<typename TReturn , typename... TArgs>
Function< TReturn(TArgs...)>::Function ( std::nullptr_t  )
inline

Definition at line 66 of file Function.h.

Member Function Documentation

◆ callIfNotNull()

template<typename TReturn , typename... TArgs>
template<typename... Ts>
void Function< TReturn(TArgs...)>::callIfNotNull ( Ts &&...  args) const
inline

Calls the function is set, otherwise it does nothing.

Definition at line 99 of file Function.h.

◆ operator bool()

template<typename TReturn , typename... TArgs>
INLINE Function< TReturn(TArgs...)>::operator bool ( ) const
inlineexplicit

Definition at line 105 of file Function.h.

◆ operator()()

template<typename TReturn , typename... TArgs>
template<typename... Ts>
TReturn Function< TReturn(TArgs...)>::operator() ( Ts &&...  args) const
inline

Calls the function, given argument list.

Definition at line 92 of file Function.h.

◆ operator=() [1/4]

template<typename TReturn , typename... TArgs>
Function& Function< TReturn(TArgs...)>::operator= ( const Function< TReturn(TArgs...)> &  other)
inline

Definition at line 75 of file Function.h.

◆ operator=() [2/4]

template<typename TReturn , typename... TArgs>
Function& Function< TReturn(TArgs...)>::operator= ( Function< TReturn(TArgs...)> &&  other)
inline

Definition at line 80 of file Function.h.

◆ operator=() [3/4]

template<typename TReturn , typename... TArgs>
Function& Function< TReturn(TArgs...)>::operator= ( std::nullptr_t  )
inline

Definition at line 85 of file Function.h.

◆ operator=() [4/4]

template<typename TReturn , typename... TArgs>
template<typename TFunctor >
Function& Function< TReturn(TArgs...)>::operator= ( TFunctor  functor)
inline

Definition at line 70 of file Function.h.


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