diff options
author | HampusM <hampus@hampusmat.com> | 2022-04-26 20:16:22 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-04-26 20:19:23 +0200 |
commit | d2a87d5803c7aaa9a47791a5a0f1494c19671ebc (patch) | |
tree | 5dcc645cafe5c1986b66b0af0c9a62663c261ecb /include/yacppdic/detail/internal/functor/copyable_functor.hpp | |
parent | dbe0e42817964b700385ac6ed7b7dc2141669e17 (diff) |
add project & make some tweaks
Added from https://git.hampusmat.com/game-of-life
Diffstat (limited to 'include/yacppdic/detail/internal/functor/copyable_functor.hpp')
-rw-r--r-- | include/yacppdic/detail/internal/functor/copyable_functor.hpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/include/yacppdic/detail/internal/functor/copyable_functor.hpp b/include/yacppdic/detail/internal/functor/copyable_functor.hpp new file mode 100644 index 0000000..b305d38 --- /dev/null +++ b/include/yacppdic/detail/internal/functor/copyable_functor.hpp @@ -0,0 +1,52 @@ +#pragma once + +#include "yacppdic/detail/internal/interfaces/copyable_functor.hpp" + +#include "yacppdic/detail/internal/functor/alloc_functor.hpp" + +#include <typeinfo> + +namespace yacppdic::internal +{ + +/** + * A copyable function object. + */ +template <class Function, class Allocator, class FunctionSignature> +class CopyableFunctor; + +template <class Function, class Allocator, class Return, class... Args> +class CopyableFunctor<Function, Allocator, Return(Args...)> + : public ICopyableFunctor<Return(Args...)> +{ +public: + explicit CopyableFunctor(Function &&function); + + explicit CopyableFunctor(const Function &function, const Allocator &allocator); + + explicit CopyableFunctor(const Function &function, Allocator &&allocator); + + explicit CopyableFunctor(Function &&function, Allocator &&allocator); + + auto operator()(Args &&...args) -> Return override; + + auto clone() const -> ICopyableFunctor<Return(Args...)> * override; + + void clone(ICopyableFunctor<Return(Args...)> *functor) const override; + + void destroy() noexcept override; + + void destroy_deallocate() noexcept override; + + [[nodiscard]] auto target(const std::type_info &type_info) const noexcept -> const + void * override; + + [[nodiscard]] auto target_type() const noexcept -> const std::type_info & override; + +private: + AllocFunctor<Function, Allocator, Return(Args...)> _functor; +}; + +} // namespace yacppdic::internal + +#include "copyable_functor-impl.hpp" |