ls1-MarDyn
ls1-MarDyn molecular dynamics code
Public Member Functions | List of all members
FunctionWrapper Class Reference

#include <FunctionWrapper.h>

Public Member Functions

 FunctionWrapper ()=default
 
 FunctionWrapper (FunctionWrapper &&other)=default
 
 FunctionWrapper (const FunctionWrapper &other)=default
 
FunctionWrapperoperator= (const FunctionWrapper &other)=default
 
FunctionWrapperoperator= (FunctionWrapper &&other)=default
 
template<typename T >
 FunctionWrapper (T &&myFunctionObject)
 
template<class R , class... Args>
auto get () const
 

Detailed Description

Class that wraps a function.

Constructor & Destructor Documentation

◆ FunctionWrapper() [1/4]

FunctionWrapper::FunctionWrapper ( )
default

Default constructor.

◆ FunctionWrapper() [2/4]

FunctionWrapper::FunctionWrapper ( FunctionWrapper &&  other)
default

Move constructor.

Parameters
other

◆ FunctionWrapper() [3/4]

FunctionWrapper::FunctionWrapper ( const FunctionWrapper other)
default

Copy constructor.

Parameters
other

◆ FunctionWrapper() [4/4]

template<typename T >
FunctionWrapper::FunctionWrapper ( T &&  myFunctionObject)
inline

Constructor for use with a lambda or function pointer. Example syntax:

  • As assignment operator, which will store a std::function<int(int)> :
    wrapper = [] (int i) { return 4 + i; };
    Definition: FunctionWrapper.h:9
  • As constructor, which will store a std::function<int()> :
    FunctionWrapper wrapper([]{return 4;})
    Template Parameters
    TThe type of the lambda or function pointer.
    Parameters
    myFunctionObjectThe function object, can, e.g., be a lambda.

Member Function Documentation

◆ get()

template<class R , class... Args>
auto FunctionWrapper::get ( ) const
inline

Get the stored function object. Example syntax:

  • to get a function without input that returns an unsigned long:
    wrapper.get<unsigned long>();
  • to get a function with unsigned long input that returns an unsigned long:
    wrapper.get<unsigned long, unsigned long>();
  • to get a function with unsigned long as input, but without output:
    wrapper.get<void, unsigned long>();
  • to get a function with two int as input that returns another int:
    wrapper.get<int, int, int>();
    Template Parameters
    RThe return type.
    ArgsThe arguments.
    Returns
    A std::function<R(Args...)> object that wraps the stored function.

◆ operator=() [1/2]

FunctionWrapper& FunctionWrapper::operator= ( const FunctionWrapper other)
default

Copy assignment operator.

Parameters
other
Returns

◆ operator=() [2/2]

FunctionWrapper& FunctionWrapper::operator= ( FunctionWrapper &&  other)
default

Move assignment operator.

Parameters
other
Returns

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