diff options
Diffstat (limited to 'src/DI')
-rw-r--r-- | src/DI/container.hpp | 16 | ||||
-rw-r--r-- | src/DI/type_traits.hpp | 16 |
2 files changed, 19 insertions, 13 deletions
diff --git a/src/DI/container.hpp b/src/DI/container.hpp index 6cb89ce..2dd194f 100644 --- a/src/DI/container.hpp +++ b/src/DI/container.hpp @@ -1,9 +1,9 @@ #pragma once +#include "DI/interfaces/wrapper.hpp" #include "DI/object_type.hpp" -#include "interfaces/wrapper.hpp" +#include "DI/type_traits.hpp" -#include <functional> #include <memory> #include <type_traits> #include <unordered_map> @@ -26,16 +26,6 @@ private: Container *_container; }; -template <typename Satan> -struct is_func : public std::false_type // NOLINT(readability-identifier-naming) -{ -}; - -template <typename Satan, typename... Args> -struct is_func<std::function<Satan(Args...)>> : public std::true_type -{ -}; - class Container { public: @@ -47,7 +37,7 @@ public: template <class Interface, class = std::enable_if_t<std::is_abstract_v<Interface>>> std::shared_ptr<Interface> get() const; - template <typename Interface, typename = std::enable_if_t<is_func<Interface>::value>> + template <typename Interface, typename = std::enable_if_t<is_func_v<Interface>>> Interface get() const; std::unordered_map<BaseObjectType, std::shared_ptr<IGenericWrapper>, ObjectTypeHasher> diff --git a/src/DI/type_traits.hpp b/src/DI/type_traits.hpp new file mode 100644 index 0000000..a852a4f --- /dev/null +++ b/src/DI/type_traits.hpp @@ -0,0 +1,16 @@ +#pragma once + +#include <functional> + +template <typename NotAFunc> +struct is_func : public std::false_type // NOLINT(readability-identifier-naming) +{ +}; + +template <typename Return, typename... Args> +struct is_func<std::function<Return(Args...)>> : public std::true_type +{ +}; + +template <typename PossiblyFunc> +inline constexpr bool is_func_v = is_func<PossiblyFunc>::value; |