ls1-MarDyn
ls1-MarDyn molecular dynamics code
FunctionWrapper.h
1#pragma once
2
3#include <any>
4#include <functional>
5
10public:
14 FunctionWrapper() = default;
15
20 FunctionWrapper(FunctionWrapper&& other) = default;
21
26 FunctionWrapper(const FunctionWrapper& other) = default;
27
33 FunctionWrapper& operator=(const FunctionWrapper& other) = default;
34
41
57 template <typename T>
58 FunctionWrapper(T&& myFunctionObject) : _myFunction{std::function(myFunctionObject)} {}
59
83 template <class R, class... Args>
84 auto get() const {
85 return std::any_cast<std::function<R(Args...)>>(_myFunction);
86 }
87
88private:
89 std::any _myFunction;
90};
Definition: FunctionWrapper.h:9
FunctionWrapper & operator=(FunctionWrapper &&other)=default
FunctionWrapper & operator=(const FunctionWrapper &other)=default
auto get() const
Definition: FunctionWrapper.h:84
FunctionWrapper(FunctionWrapper &&other)=default
FunctionWrapper()=default
FunctionWrapper(const FunctionWrapper &other)=default
FunctionWrapper(T &&myFunctionObject)
Definition: FunctionWrapper.h:58