14 template <
typename TSignature>
17 template <
typename TReturn,
typename... TArgs>
24 template <
typename TSignature>
30 template <
typename TReturn,
typename... TArgs>
35 template <
typename TFunctor>
41 FunctorCallable(TFunctor&& functor)
42 : functor(std::forward<TFunctor>(functor)) {}
44 virtual TReturn operator()(TArgs... args)
override {
45 return functor(args...);
56 template <
typename TFunctor,
typename = std::enable_if_t<
IsCallable<TFunctor, TArgs...>::value>>
58 : holder(
makeShared<FunctorCallable<TFunctor>>(
std::move(functor))) {}
61 : holder(other.holder) {}
64 : holder(
std::move(other.holder)) {}
69 template <
typename TFunctor>
71 holder = makeShared<FunctorCallable<TFunctor>>(std::move(functor));
76 holder = other.holder;
81 holder = std::move(other.holder);
91 template <
typename... Ts>
94 return (*holder)(std::forward<Ts>(args)...);
98 template <
typename... Ts>
101 this->operator()(std::forward<Ts>(args)...);
#define SPH_ASSERT(x,...)
#define INLINE
Macros for conditional compilation based on selected compiler.
#define NAMESPACE_SPH_END
INLINE SharedPtr< T > makeShared(TArgs &&... args)
Few non-standard type traits.
virtual TReturn operator()(TArgs... args)=0
Function(const Function &other)
Function & operator=(TFunctor functor)
Function & operator=(const Function &other)
Function & operator=(Function &&other)
Function(TFunctor functor)
Creates a function given a callable object.
TReturn operator()(Ts &&... args) const
Calls the function, given argument list.
Function(Function &&other)
Function & operator=(std::nullptr_t)
void callIfNotNull(Ts &&... args) const
Calls the function is set, otherwise it does nothing.
Overload of std::swap for Sph::Array.
Base class for all polymorphic objects.