diff options
author | HampusM <hampus@hampusmat.com> | 2022-04-30 16:28:13 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-06-13 17:56:58 +0200 |
commit | 40d02748924aa7c48b04cf948204d8dacdfbbc74 (patch) | |
tree | 4d07a3703207295799b02cef52618a8f0c820542 /src/DI/alloc_functor.hpp | |
parent | db6edcd473a684420e9a7611b24462df21165c1b (diff) |
refactor: replace DI files with the yacppdic library
Diffstat (limited to 'src/DI/alloc_functor.hpp')
-rw-r--r-- | src/DI/alloc_functor.hpp | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/src/DI/alloc_functor.hpp b/src/DI/alloc_functor.hpp deleted file mode 100644 index ea40b22..0000000 --- a/src/DI/alloc_functor.hpp +++ /dev/null @@ -1,84 +0,0 @@ -#pragma once - -#include "DI/allocation.hpp" -#include "DI/compressed_pair.hpp" - -#include <memory> -#include <type_traits> -#include <utility> - -template <typename Return> -struct InvokeReturnWrapper -{ - template <typename... Args> - static auto call(Args &&...args) -> Return; -}; - -/** - * Holds a functor and a allocator. - */ -template <class Function, class Allocator, class FunctionSignature> -class AllocFunctor; - -template <class Function, class Allocator, class Return, class... Args> -class AllocFunctor<Function, Allocator, Return(Args...)> -{ -public: - using Target = Function; - using Alloc = Allocator; - - explicit AllocFunctor(Target &&function); - - explicit AllocFunctor(const Target &function, const Alloc &allocator); - - explicit AllocFunctor(const Target &function, Alloc &&allocator); - - explicit AllocFunctor(Target &&function, Alloc &&allocator); - - auto operator()(Args &&...args) -> Return; - - [[nodiscard]] auto target() const -> const Target &; - - [[nodiscard]] auto get_allocator() const -> const Alloc &; - - [[nodiscard]] auto clone() const -> AllocFunctor *; - - void destroy() noexcept; - - static void destroy_and_delete(AllocFunctor *functor); - -private: - CompressedPair<Function, Allocator> _function; -}; - -/** - * Holds a functor and a allocator. - */ -template <class Function, class FB> -class DefaultAllocFunctor; - -template <class Function, class Return, class... Args> -class DefaultAllocFunctor<Function, Return(Args...)> -{ -public: - using Target = Function; - - explicit DefaultAllocFunctor(Target &&function); - - explicit DefaultAllocFunctor(const Target &function); - - auto operator()(Args &&...args) -> Return; - - auto target() const -> const Target &; - - auto clone() const -> DefaultAllocFunctor *; - - void destroy() noexcept; - - static void destroy_and_delete(DefaultAllocFunctor *function); - -private: - Function _function; -}; - -#include "alloc_functor.tpp" |