aboutsummaryrefslogtreecommitdiff
path: root/src/DI
diff options
context:
space:
mode:
Diffstat (limited to 'src/DI')
-rw-r--r--src/DI/alloc_functor.tpp34
-rw-r--r--src/DI/allocation.tpp6
-rw-r--r--src/DI/auto_wirable.tpp3
-rw-r--r--src/DI/compressed_pair.hpp42
-rw-r--r--src/DI/container.cpp7
-rw-r--r--src/DI/container.tpp20
-rw-r--r--src/DI/copyable_functor.tpp6
-rw-r--r--src/DI/factory.hpp9
-rw-r--r--src/DI/function_wrapper.tpp3
-rw-r--r--src/DI/object_type.cpp5
-rw-r--r--src/DI/value_functor.tpp4
11 files changed, 93 insertions, 46 deletions
diff --git a/src/DI/alloc_functor.tpp b/src/DI/alloc_functor.tpp
index d3f6946..9611a3d 100644
--- a/src/DI/alloc_functor.tpp
+++ b/src/DI/alloc_functor.tpp
@@ -18,29 +18,41 @@ auto InvokeReturnWrapper<Return>::call(Args &&...args) -> Return
ALLOC_FUNCTOR_TEMPLATE
ALLOC_FUNCTOR::AllocFunctor(Target &&function)
- : _function(std::piecewise_construct, std::forward_as_tuple(std::move(function)),
- std::forward_as_tuple())
+ : _function(
+ std::piecewise_construct,
+ std::forward_as_tuple(std::move(function)),
+ std::forward_as_tuple()
+ )
{
}
ALLOC_FUNCTOR_TEMPLATE
ALLOC_FUNCTOR::AllocFunctor(const Target &function, const Alloc &allocator)
- : _function(std::piecewise_construct, std::forward_as_tuple(function),
- std::forward_as_tuple(allocator))
+ : _function(
+ std::piecewise_construct,
+ std::forward_as_tuple(function),
+ std::forward_as_tuple(allocator)
+ )
{
}
ALLOC_FUNCTOR_TEMPLATE
ALLOC_FUNCTOR::AllocFunctor(const Target &function, Alloc &&allocator)
- : _function(std::piecewise_construct, std::forward_as_tuple(function),
- std::forward_as_tuple(std::move(allocator)))
+ : _function(
+ std::piecewise_construct,
+ std::forward_as_tuple(function),
+ std::forward_as_tuple(std::move(allocator))
+ )
{
}
ALLOC_FUNCTOR_TEMPLATE
ALLOC_FUNCTOR::AllocFunctor(Target &&function, Alloc &&allocator)
- : _function(std::piecewise_construct, std::forward_as_tuple(std::move(function)),
- std::forward_as_tuple(std::move(allocator)))
+ : _function(
+ std::piecewise_construct,
+ std::forward_as_tuple(std::move(function)),
+ std::forward_as_tuple(std::move(allocator))
+ )
{
}
@@ -75,8 +87,10 @@ auto ALLOC_FUNCTOR::clone() const -> AllocFunctor *
using Destructor = AllocDestructor<AllocHelper>;
- auto hold = std::unique_ptr<AllocFunctor, Destructor>(alloc_helper.allocate(1),
- _Dp(alloc_helper, 1));
+ auto hold = std::unique_ptr<AllocFunctor, Destructor>(
+ alloc_helper.allocate(1),
+ _Dp(alloc_helper, 1)
+ );
::new (static_cast<void *>(hold.get()))
AllocFunctor(_function.first(), _Alloc(alloc_helper));
diff --git a/src/DI/allocation.tpp b/src/DI/allocation.tpp
index 245ce99..8753970 100644
--- a/src/DI/allocation.tpp
+++ b/src/DI/allocation.tpp
@@ -3,8 +3,10 @@
#include "allocation.hpp"
template <class Allocator>
-AllocDestructor<Allocator>::AllocDestructor(Allocator &allocator,
- Size alloc_size) noexcept
+AllocDestructor<Allocator>::AllocDestructor(
+ Allocator &allocator,
+ Size alloc_size
+) noexcept
: _allocator(allocator), _size(alloc_size)
{
}
diff --git a/src/DI/auto_wirable.tpp b/src/DI/auto_wirable.tpp
index 0a9ca93..4ad34c4 100644
--- a/src/DI/auto_wirable.tpp
+++ b/src/DI/auto_wirable.tpp
@@ -4,7 +4,8 @@
template <class Interface, class ObjectImpl, class... Dependencies>
auto AutoWirable<Interface, ObjectImpl, Dependencies...>::resolve(
- const Container &container) noexcept -> std::unique_ptr<Interface>
+ const Container &container
+) noexcept -> std::unique_ptr<Interface>
{
return std::make_unique<ObjectImpl>(container.get<Dependencies>()...);
}
diff --git a/src/DI/compressed_pair.hpp b/src/DI/compressed_pair.hpp
index 6e05e29..b8646db 100644
--- a/src/DI/compressed_pair.hpp
+++ b/src/DI/compressed_pair.hpp
@@ -33,8 +33,8 @@ struct IntegerSequence
template <size_t SizeOne, size_t SizeTwo>
using MakeIndices =
- typename __make_integer_seq<IntegerSequence, size_t,
- SizeOne - SizeTwo>::template ToTupleIndices<SizeTwo>;
+ typename __make_integer_seq<IntegerSequence, size_t, SizeOne - SizeTwo>::
+ template ToTupleIndices<SizeTwo>;
template <size_t SizeOne, size_t SizeTwo = 0>
requires(SizeTwo <= SizeOne) struct MakeTupleIndices
@@ -64,9 +64,11 @@ struct CompressedPairElement
}
template <class... Args, size_t... Indexes>
- constexpr CompressedPairElement(std::piecewise_construct_t /*unused*/,
- std::tuple<Args...> args,
- TupleIndices<Indexes...> /*unused*/)
+ constexpr CompressedPairElement(
+ std::piecewise_construct_t /*unused*/,
+ std::tuple<Args...> args,
+ TupleIndices<Indexes...> /*unused*/
+ )
: _value(std::forward<Args>(std::get<Indexes>(args))...)
{
}
@@ -107,9 +109,11 @@ struct CompressedPairElement<Value, Idx> : private Value
}
template <class... Args, size_t... Indexes>
- constexpr CompressedPairElement(std::piecewise_construct_t /*unused*/,
- std::tuple<Args...> args,
- TupleIndices<Indexes...> /*unused*/)
+ constexpr CompressedPairElement(
+ std::piecewise_construct_t /*unused*/,
+ std::tuple<Args...> args,
+ TupleIndices<Indexes...> /*unused*/
+ )
: Value(std::forward<Args>(std::get<Indexes>(args))...)
{
}
@@ -146,13 +150,21 @@ public:
}
template <class... ArgsOne, class... ArgsTwo>
- constexpr CompressedPair(std::piecewise_construct_t piecewise_construct,
- std::tuple<ArgsOne...> first_args,
- std::tuple<ArgsTwo...> second_args)
- : BaseOne(piecewise_construct, std::move(first_args),
- typename MakeTupleIndices<sizeof...(ArgsOne)>::type()),
- BaseTwo(piecewise_construct, std::move(second_args),
- typename MakeTupleIndices<sizeof...(ArgsTwo)>::type())
+ constexpr CompressedPair(
+ std::piecewise_construct_t piecewise_construct,
+ std::tuple<ArgsOne...> first_args,
+ std::tuple<ArgsTwo...> second_args
+ )
+ : BaseOne(
+ piecewise_construct,
+ std::move(first_args),
+ typename MakeTupleIndices<sizeof...(ArgsOne)>::type()
+ ),
+ BaseTwo(
+ piecewise_construct,
+ std::move(second_args),
+ typename MakeTupleIndices<sizeof...(ArgsTwo)>::type()
+ )
{
}
diff --git a/src/DI/container.cpp b/src/DI/container.cpp
index 1b5dc55..f27b1fa 100644
--- a/src/DI/container.cpp
+++ b/src/DI/container.cpp
@@ -1,6 +1,9 @@
#include "container.hpp"
-void Container::add(BaseObjectType type, const WrapperPtr<IGenericWrapper> &wrapper) noexcept
+void Container::add(
+ BaseObjectType type,
+ const WrapperPtr<IGenericWrapper> &wrapper
+) noexcept
{
- _bindings.insert({type, wrapper});
+ _bindings.insert({ type, wrapper });
}
diff --git a/src/DI/container.tpp b/src/DI/container.tpp
index 13397bc..d81a0cc 100644
--- a/src/DI/container.tpp
+++ b/src/DI/container.tpp
@@ -22,8 +22,10 @@ void BindingBuilder<Interface>::to() noexcept
auto wrapper = Container::WrapperPtr<Wrapper>(new Wrapper(*_container));
- _container->add(ObjectType<Interface>(),
- std::dynamic_pointer_cast<IGenericWrapper>(wrapper));
+ _container->add(
+ ObjectType<Interface>(),
+ std::dynamic_pointer_cast<IGenericWrapper>(wrapper)
+ );
}
template <typename Interface>
@@ -35,8 +37,10 @@ void BindingBuilder<Interface>::to_factory(FactoryFunc factory) noexcept
auto wrapper = Container::WrapperPtr<Wrapper>(new Wrapper(factory));
- _container->add(ObjectType<Interface>(),
- std::dynamic_pointer_cast<IGenericWrapper>(wrapper));
+ _container->add(
+ ObjectType<Interface>(),
+ std::dynamic_pointer_cast<IGenericWrapper>(wrapper)
+ );
}
template <typename Interface>
@@ -60,7 +64,8 @@ auto Container::get() const noexcept -> std::unique_ptr<Interface>
}
auto wrapper = std::dynamic_pointer_cast<IWrapper<std::unique_ptr<Interface>>>(
- _bindings.at(interface_type));
+ _bindings.at(interface_type)
+ );
return wrapper->get();
}
@@ -69,8 +74,9 @@ template <typename AFactory>
requires IsFactory<AFactory>
auto Container::get() const noexcept -> AFactory
{
- auto wrapper = std::dynamic_pointer_cast<IWrapper<AFactory>>(
- _bindings.at(ObjectType<AFactory>()));
+ auto wrapper =
+ std::dynamic_pointer_cast<IWrapper<AFactory>>(_bindings.at(ObjectType<AFactory>())
+ );
return wrapper->get();
}
diff --git a/src/DI/copyable_functor.tpp b/src/DI/copyable_functor.tpp
index 9895397..d8da3bb 100644
--- a/src/DI/copyable_functor.tpp
+++ b/src/DI/copyable_functor.tpp
@@ -50,8 +50,10 @@ auto COPYABLE_FUNCTOR::clone() const -> ICopyableFunctor<Return(Args...)> *
using Destructor = AllocDestructor<AllocHelper>;
- auto hold = std::unique_ptr<CopyableFunctor, Destructor>(alloc_helper.allocate(1),
- Destructor(alloc_helper, 1));
+ auto hold = std::unique_ptr<CopyableFunctor, Destructor>(
+ alloc_helper.allocate(1),
+ Destructor(alloc_helper, 1)
+ );
::new (static_cast<void *>(hold.get()))
CopyableFunctor(_functor.target(), Allocator(alloc_helper));
diff --git a/src/DI/factory.hpp b/src/DI/factory.hpp
index 13d0eb5..035e557 100644
--- a/src/DI/factory.hpp
+++ b/src/DI/factory.hpp
@@ -83,7 +83,9 @@ struct is_core_convertible : public std::false_type
template <class Tp, class Up>
struct is_core_convertible<
- Tp, Up, decltype(static_cast<void (*)(Up)>(0)(static_cast<Tp (*)()>(0)()))>
+ Tp,
+ Up,
+ decltype(static_cast<void (*)(Up)>(0)(static_cast<Tp (*)()>(0)()))>
: public std::true_type
{
};
@@ -154,8 +156,9 @@ private:
template <class Return, class... Args>
Factory(Return (*)(Args...)) -> Factory<Return(Args...)>;
-template <class Function,
- class Stripped = strip_signature_t<decltype(&Function::operator())>>
+template <
+ class Function,
+ class Stripped = strip_signature_t<decltype(&Function::operator())>>
Factory(Function) -> Factory<Stripped>;
template <class Return, class... Args>
diff --git a/src/DI/function_wrapper.tpp b/src/DI/function_wrapper.tpp
index d672a49..c7afc3d 100644
--- a/src/DI/function_wrapper.tpp
+++ b/src/DI/function_wrapper.tpp
@@ -5,7 +5,8 @@
#include "function_wrapper.hpp"
template <class Interface>
-FunctionWrapper<Interface>::FunctionWrapper(Interface func) noexcept : _func(std::move(func))
+FunctionWrapper<Interface>::FunctionWrapper(Interface func) noexcept
+ : _func(std::move(func))
{
}
diff --git a/src/DI/object_type.cpp b/src/DI/object_type.cpp
index 64a23fa..d7116e8 100644
--- a/src/DI/object_type.cpp
+++ b/src/DI/object_type.cpp
@@ -17,10 +17,11 @@ auto BaseObjectType::hash() const noexcept -> std::size_t
auto BaseObjectType::name() const noexcept -> std::string_view
{
- return {_type_info.name()};
+ return { _type_info.name() };
}
-auto ObjectTypeHasher::operator()(const BaseObjectType &object_type) const noexcept -> std::size_t
+auto ObjectTypeHasher::operator()(const BaseObjectType &object_type) const noexcept
+ -> std::size_t
{
return object_type.hash();
}
diff --git a/src/DI/value_functor.tpp b/src/DI/value_functor.tpp
index 3665f18..a41d1c2 100644
--- a/src/DI/value_functor.tpp
+++ b/src/DI/value_functor.tpp
@@ -39,7 +39,9 @@ VALUE_FUNCTOR::ValueFunctor(Function &&function, const Allocator &allocator)
using Destructor = AllocDestructor<FunctorAlloc>;
auto hold = std::unique_ptr<TargetFunctor, Destructor>(
- functor_alloc.allocate(1), Destructor(functor_alloc, 1));
+ functor_alloc.allocate(1),
+ Destructor(functor_alloc, 1)
+ );
::new (static_cast<void *>(hold.get()))
Functor(std::forward<Function>(function), Allocator(allocator));