aboutsummaryrefslogtreecommitdiff
path: root/src/DI
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-03-29 17:40:04 +0200
committerHampusM <hampus@hampusmat.com>2022-06-13 17:56:57 +0200
commita039c8ad36779903571419cb06cd052f8fc41512 (patch)
tree4fdced6941a048bdd4b032fab7012bca00a6028e /src/DI
parentacf72075ed32e5a679d49ffedc0c28d8ac2aea8b (diff)
refactor: use trailing return types
Diffstat (limited to 'src/DI')
-rw-r--r--src/DI/auto_wirable.hpp4
-rw-r--r--src/DI/auto_wirable.tpp4
-rw-r--r--src/DI/container.hpp6
-rw-r--r--src/DI/container.tpp6
-rw-r--r--src/DI/function_wrapper.hpp2
-rw-r--r--src/DI/function_wrapper.tpp2
-rw-r--r--src/DI/interfaces/wrapper.hpp2
-rw-r--r--src/DI/object_type.cpp10
-rw-r--r--src/DI/object_type.hpp8
-rw-r--r--src/DI/object_wrapper.hpp2
-rw-r--r--src/DI/object_wrapper.tpp2
11 files changed, 24 insertions, 24 deletions
diff --git a/src/DI/auto_wirable.hpp b/src/DI/auto_wirable.hpp
index 178158a..54a291e 100644
--- a/src/DI/auto_wirable.hpp
+++ b/src/DI/auto_wirable.hpp
@@ -8,14 +8,14 @@ template <class Interface>
class IAutoWirable
{
public:
- static Interface resolve() noexcept;
+ static auto resolve() noexcept -> Interface;
};
template <class Interface, class ObjectImpl, class... Dependencies>
class AutoWirable : public IAutoWirable<Interface>
{
public:
- static std::shared_ptr<Interface> resolve(const Container &container) noexcept;
+ static auto resolve(const Container &container) noexcept -> std::shared_ptr<Interface>;
};
#include "auto_wirable.tpp"
diff --git a/src/DI/auto_wirable.tpp b/src/DI/auto_wirable.tpp
index a99d82b..3b42cc4 100644
--- a/src/DI/auto_wirable.tpp
+++ b/src/DI/auto_wirable.tpp
@@ -3,8 +3,8 @@
#include "auto_wirable.hpp"
template <class Interface, class ObjectImpl, class... Dependencies>
-std::shared_ptr<Interface> AutoWirable<Interface, ObjectImpl, Dependencies...>::resolve(
- const Container &container) noexcept
+auto AutoWirable<Interface, ObjectImpl, Dependencies...>::resolve(
+ const Container &container) noexcept -> std::shared_ptr<Interface>
{
return std::make_shared<ObjectImpl>(container.get<Dependencies>()...);
}
diff --git a/src/DI/container.hpp b/src/DI/container.hpp
index 2efb265..83f24ae 100644
--- a/src/DI/container.hpp
+++ b/src/DI/container.hpp
@@ -32,13 +32,13 @@ public:
Container() noexcept = default;
template <class Interface>
- BindingBuilder<Interface> bind() noexcept;
+ auto bind() noexcept -> BindingBuilder<Interface>;
template <class Interface, class = std::enable_if_t<std::is_abstract_v<Interface>>>
- std::shared_ptr<Interface> get() const noexcept;
+ auto get() const noexcept -> std::shared_ptr<Interface>;
template <typename Interface, typename = std::enable_if_t<is_func_v<Interface>>>
- Interface get() const noexcept;
+ auto get() const noexcept -> Interface;
std::unordered_map<BaseObjectType, std::shared_ptr<IGenericWrapper>, ObjectTypeHasher>
bindings;
diff --git a/src/DI/container.tpp b/src/DI/container.tpp
index ed7f34f..2573223 100644
--- a/src/DI/container.tpp
+++ b/src/DI/container.tpp
@@ -32,13 +32,13 @@ void BindingBuilder<Interface>::to_factory(Interface func) noexcept
}
template <class Interface>
-BindingBuilder<Interface> Container::bind() noexcept
+auto Container::bind() noexcept -> BindingBuilder<Interface>
{
return BindingBuilder<Interface>(this);
}
template <class Interface, class>
-std::shared_ptr<Interface> Container::get() const noexcept
+auto Container::get() const noexcept -> std::shared_ptr<Interface>
{
ObjectType<Interface> interface_type;
@@ -57,7 +57,7 @@ std::shared_ptr<Interface> Container::get() const noexcept
}
template <typename Interface, typename>
-Interface Container::get() const noexcept
+auto Container::get() const noexcept -> Interface
{
auto wrapper = std::dynamic_pointer_cast<IWrapper<Interface>>(
bindings.at(ObjectType<Interface>()));
diff --git a/src/DI/function_wrapper.hpp b/src/DI/function_wrapper.hpp
index e6468f2..b8d0cab 100644
--- a/src/DI/function_wrapper.hpp
+++ b/src/DI/function_wrapper.hpp
@@ -11,7 +11,7 @@ class FunctionWrapper : public IWrapper<Interface>
public:
explicit FunctionWrapper(Interface func) noexcept;
- [[nodiscard]] Interface get() const noexcept override;
+ [[nodiscard]] auto get() const noexcept -> Interface override;
private:
const Interface _func;
diff --git a/src/DI/function_wrapper.tpp b/src/DI/function_wrapper.tpp
index 540a7aa..6a9c317 100644
--- a/src/DI/function_wrapper.tpp
+++ b/src/DI/function_wrapper.tpp
@@ -8,7 +8,7 @@ FunctionWrapper<Interface>::FunctionWrapper(Interface func) noexcept : _func(fun
}
template <class Interface>
-Interface FunctionWrapper<Interface>::get() const noexcept
+auto FunctionWrapper<Interface>::get() const noexcept -> Interface
{
return _func;
}
diff --git a/src/DI/interfaces/wrapper.hpp b/src/DI/interfaces/wrapper.hpp
index cde555f..e22ea7f 100644
--- a/src/DI/interfaces/wrapper.hpp
+++ b/src/DI/interfaces/wrapper.hpp
@@ -13,5 +13,5 @@ template <class Interface>
class IWrapper : public IGenericWrapper
{
public:
- [[nodiscard]] virtual Interface get() const noexcept = 0;
+ [[nodiscard]] virtual auto get() const noexcept -> Interface = 0;
};
diff --git a/src/DI/object_type.cpp b/src/DI/object_type.cpp
index 008c4a4..64a23fa 100644
--- a/src/DI/object_type.cpp
+++ b/src/DI/object_type.cpp
@@ -5,22 +5,22 @@ BaseObjectType::BaseObjectType(const std::type_info &type_info) noexcept
{
}
-bool BaseObjectType::operator==(const BaseObjectType &object_type) const noexcept
+auto BaseObjectType::operator==(const BaseObjectType &object_type) const noexcept -> bool
{
return hash() == object_type.hash();
}
-std::size_t BaseObjectType::hash() const noexcept
+auto BaseObjectType::hash() const noexcept -> std::size_t
{
return _type_info.hash_code();
}
-std::string_view BaseObjectType::name() const noexcept
+auto BaseObjectType::name() const noexcept -> std::string_view
{
- return std::string_view(_type_info.name());
+ return {_type_info.name()};
}
-std::size_t ObjectTypeHasher::operator()(const BaseObjectType &object_type) const noexcept
+auto ObjectTypeHasher::operator()(const BaseObjectType &object_type) const noexcept -> std::size_t
{
return object_type.hash();
}
diff --git a/src/DI/object_type.hpp b/src/DI/object_type.hpp
index 6b27682..5107dbf 100644
--- a/src/DI/object_type.hpp
+++ b/src/DI/object_type.hpp
@@ -8,11 +8,11 @@ class BaseObjectType
public:
explicit BaseObjectType(const std::type_info &type_info) noexcept;
- bool operator==(const BaseObjectType &object_type) const noexcept;
+ auto operator==(const BaseObjectType &object_type) const noexcept -> bool;
- [[nodiscard]] std::size_t hash() const noexcept;
+ [[nodiscard]] auto hash() const noexcept -> std::size_t;
- [[nodiscard]] std::string_view name() const noexcept;
+ [[nodiscard]] auto name() const noexcept -> std::string_view;
private:
const std::type_info &_type_info;
@@ -28,5 +28,5 @@ public:
class ObjectTypeHasher
{
public:
- std::size_t operator()(const BaseObjectType &object_type) const noexcept;
+ auto operator()(const BaseObjectType &object_type) const noexcept -> std::size_t;
};
diff --git a/src/DI/object_wrapper.hpp b/src/DI/object_wrapper.hpp
index 4aee9af..28121cb 100644
--- a/src/DI/object_wrapper.hpp
+++ b/src/DI/object_wrapper.hpp
@@ -11,7 +11,7 @@ class ObjectWrapper : public IWrapper<std::shared_ptr<Interface>>
public:
explicit ObjectWrapper(const Container &container) noexcept : _container(container) {}
- [[nodiscard]] std::shared_ptr<Interface> get() const noexcept override;
+ [[nodiscard]] auto get() const noexcept -> std::shared_ptr<Interface> override;
private:
const Container &_container;
diff --git a/src/DI/object_wrapper.tpp b/src/DI/object_wrapper.tpp
index bbb7bee..5334247 100644
--- a/src/DI/object_wrapper.tpp
+++ b/src/DI/object_wrapper.tpp
@@ -3,7 +3,7 @@
#include "object_wrapper.hpp"
template <class Interface, class ObjectImpl>
-std::shared_ptr<Interface> ObjectWrapper<Interface, ObjectImpl>::get() const noexcept
+auto ObjectWrapper<Interface, ObjectImpl>::get() const noexcept -> std::shared_ptr<Interface>
{
return ObjectImpl::resolve(_container);
}