From db6edcd473a684420e9a7611b24462df21165c1b Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 24 Apr 2022 17:13:52 +0200 Subject: style: improve function and brace styling --- src/DI/alloc_functor.tpp | 34 ++++++++++++++++++++++++---------- src/DI/allocation.tpp | 6 ++++-- src/DI/auto_wirable.tpp | 3 ++- src/DI/compressed_pair.hpp | 42 +++++++++++++++++++++++++++--------------- src/DI/container.cpp | 7 +++++-- src/DI/container.tpp | 20 +++++++++++++------- src/DI/copyable_functor.tpp | 6 ++++-- src/DI/factory.hpp | 9 ++++++--- src/DI/function_wrapper.tpp | 3 ++- src/DI/object_type.cpp | 5 +++-- src/DI/value_functor.tpp | 4 +++- 11 files changed, 93 insertions(+), 46 deletions(-) (limited to 'src/DI') 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::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; - auto hold = std::unique_ptr(alloc_helper.allocate(1), - _Dp(alloc_helper, 1)); + auto hold = std::unique_ptr( + alloc_helper.allocate(1), + _Dp(alloc_helper, 1) + ); ::new (static_cast(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 -AllocDestructor::AllocDestructor(Allocator &allocator, - Size alloc_size) noexcept +AllocDestructor::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 auto AutoWirable::resolve( - const Container &container) noexcept -> std::unique_ptr + const Container &container +) noexcept -> std::unique_ptr { return std::make_unique(container.get()...); } 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 using MakeIndices = - typename __make_integer_seq::template ToTupleIndices; + typename __make_integer_seq:: + template ToTupleIndices; template requires(SizeTwo <= SizeOne) struct MakeTupleIndices @@ -64,9 +64,11 @@ struct CompressedPairElement } template - constexpr CompressedPairElement(std::piecewise_construct_t /*unused*/, - std::tuple args, - TupleIndices /*unused*/) + constexpr CompressedPairElement( + std::piecewise_construct_t /*unused*/, + std::tuple args, + TupleIndices /*unused*/ + ) : _value(std::forward(std::get(args))...) { } @@ -107,9 +109,11 @@ struct CompressedPairElement : private Value } template - constexpr CompressedPairElement(std::piecewise_construct_t /*unused*/, - std::tuple args, - TupleIndices /*unused*/) + constexpr CompressedPairElement( + std::piecewise_construct_t /*unused*/, + std::tuple args, + TupleIndices /*unused*/ + ) : Value(std::forward(std::get(args))...) { } @@ -146,13 +150,21 @@ public: } template - constexpr CompressedPair(std::piecewise_construct_t piecewise_construct, - std::tuple first_args, - std::tuple second_args) - : BaseOne(piecewise_construct, std::move(first_args), - typename MakeTupleIndices::type()), - BaseTwo(piecewise_construct, std::move(second_args), - typename MakeTupleIndices::type()) + constexpr CompressedPair( + std::piecewise_construct_t piecewise_construct, + std::tuple first_args, + std::tuple second_args + ) + : BaseOne( + piecewise_construct, + std::move(first_args), + typename MakeTupleIndices::type() + ), + BaseTwo( + piecewise_construct, + std::move(second_args), + typename MakeTupleIndices::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 &wrapper) noexcept +void Container::add( + BaseObjectType type, + const WrapperPtr &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::to() noexcept auto wrapper = Container::WrapperPtr(new Wrapper(*_container)); - _container->add(ObjectType(), - std::dynamic_pointer_cast(wrapper)); + _container->add( + ObjectType(), + std::dynamic_pointer_cast(wrapper) + ); } template @@ -35,8 +37,10 @@ void BindingBuilder::to_factory(FactoryFunc factory) noexcept auto wrapper = Container::WrapperPtr(new Wrapper(factory)); - _container->add(ObjectType(), - std::dynamic_pointer_cast(wrapper)); + _container->add( + ObjectType(), + std::dynamic_pointer_cast(wrapper) + ); } template @@ -60,7 +64,8 @@ auto Container::get() const noexcept -> std::unique_ptr } auto wrapper = std::dynamic_pointer_cast>>( - _bindings.at(interface_type)); + _bindings.at(interface_type) + ); return wrapper->get(); } @@ -69,8 +74,9 @@ template requires IsFactory auto Container::get() const noexcept -> AFactory { - auto wrapper = std::dynamic_pointer_cast>( - _bindings.at(ObjectType())); + auto wrapper = + std::dynamic_pointer_cast>(_bindings.at(ObjectType()) + ); 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 * using Destructor = AllocDestructor; - auto hold = std::unique_ptr(alloc_helper.allocate(1), - Destructor(alloc_helper, 1)); + auto hold = std::unique_ptr( + alloc_helper.allocate(1), + Destructor(alloc_helper, 1) + ); ::new (static_cast(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 struct is_core_convertible< - Tp, Up, decltype(static_cast(0)(static_cast(0)()))> + Tp, + Up, + decltype(static_cast(0)(static_cast(0)()))> : public std::true_type { }; @@ -154,8 +156,9 @@ private: template Factory(Return (*)(Args...)) -> Factory; -template > +template < + class Function, + class Stripped = strip_signature_t> Factory(Function) -> Factory; template 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 -FunctionWrapper::FunctionWrapper(Interface func) noexcept : _func(std::move(func)) +FunctionWrapper::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; auto hold = std::unique_ptr( - functor_alloc.allocate(1), Destructor(functor_alloc, 1)); + functor_alloc.allocate(1), + Destructor(functor_alloc, 1) + ); ::new (static_cast(hold.get())) Functor(std::forward(function), Allocator(allocator)); -- cgit v1.2.3-18-g5258