diff options
author | HampusM <hampus@hampusmat.com> | 2022-06-09 16:58:36 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-06-09 16:58:36 +0200 |
commit | 58762e6e029d71ed72b094ec2d5831b6cac4e27b (patch) | |
tree | 2734ac830726b2bc4be2bccb07f7cc3688fc9adc | |
parent | 27ceb30d1f65d36e99b841055b9b9bd406a354cb (diff) |
style: fix misc code style issues
-rw-r--r-- | include/yacppdic/container.hpp | 4 | ||||
-rw-r--r-- | include/yacppdic/detail/container-impl.hpp | 11 | ||||
-rw-r--r-- | include/yacppdic/detail/internal/alloc_destructor-impl.hpp | 2 | ||||
-rw-r--r-- | include/yacppdic/detail/internal/hash.hpp | 2 | ||||
-rw-r--r-- | include/yacppdic/detail/internal/wrapper/function_wrapper-impl.hpp | 2 | ||||
-rw-r--r-- | include/yacppdic/object_type.hpp | 4 | ||||
-rw-r--r-- | include/yacppdic/tagged.hpp | 7 |
7 files changed, 17 insertions, 15 deletions
diff --git a/include/yacppdic/container.hpp b/include/yacppdic/container.hpp index c206d39..6308142 100644 --- a/include/yacppdic/container.hpp +++ b/include/yacppdic/container.hpp @@ -23,7 +23,7 @@ class BindingWhen public: explicit BindingWhen( Container *container, - const BaseObjectType &object_type + BaseObjectType object_type ) noexcept; void when_tagged(std::string_view tag) noexcept; @@ -83,7 +83,7 @@ public: void remove(const BaseObjectType &type) noexcept; - WrapperPtr<IGenericWrapper> at(const BaseObjectType &type) const noexcept; + auto at(const BaseObjectType &type) const noexcept -> WrapperPtr<IGenericWrapper>; private: std::unordered_map<BaseObjectType, WrapperPtr<IGenericWrapper>, ObjectTypeHasher> diff --git a/include/yacppdic/detail/container-impl.hpp b/include/yacppdic/detail/container-impl.hpp index 952d510..869641c 100644 --- a/include/yacppdic/detail/container-impl.hpp +++ b/include/yacppdic/detail/container-impl.hpp @@ -5,6 +5,7 @@ #include "yacppdic/detail/internal/wrapper/object_wrapper.hpp" #include <iostream> +#include <utility> namespace yacppdic { @@ -12,9 +13,9 @@ namespace yacppdic template <typename Interface> BindingWhen<Interface>::BindingWhen( Container *container, - const BaseObjectType &object_type + BaseObjectType object_type ) noexcept - : _container(container), _object_type(object_type) + : _container(container), _object_type(std::move(object_type)) { } @@ -102,7 +103,7 @@ auto Container::get() const noexcept -> AFactory { BaseObjectType type = ObjectType<AFactory>(); - if (_bindings.count(type) == 0) + if (!_bindings.contains(type)) { std::cerr << "Error: Tried to get a item from the container using unbound interface '" @@ -121,7 +122,7 @@ auto Container::get_tagged(const char *tag) const noexcept -> std::unique_ptr<In { BaseObjectType type = ObjectType<Interface>(tag); - if (_bindings.count(type) == 0) + if (!_bindings.contains(type)) { std::cerr << "Error: Tried to get a item from the container using unbound interface '" @@ -142,7 +143,7 @@ auto Container::get_tagged(const char *tag) const noexcept -> AFactory { BaseObjectType type = ObjectType<AFactory>(tag); - if (_bindings.count(type) == 0) + if (!_bindings.contains(type)) { std::cerr << "Error: Tried to get a item from the container using unbound interface '" diff --git a/include/yacppdic/detail/internal/alloc_destructor-impl.hpp b/include/yacppdic/detail/internal/alloc_destructor-impl.hpp index d7eb5eb..2af25f2 100644 --- a/include/yacppdic/detail/internal/alloc_destructor-impl.hpp +++ b/include/yacppdic/detail/internal/alloc_destructor-impl.hpp @@ -20,4 +20,4 @@ void AllocDestructor<Allocator>::operator()(Pointer ptr) noexcept AllocTraits::deallocate(_allocator, ptr, _size); } -} +} // namespace yacppdic::internal diff --git a/include/yacppdic/detail/internal/hash.hpp b/include/yacppdic/detail/internal/hash.hpp index 145f048..1a260b4 100644 --- a/include/yacppdic/detail/internal/hash.hpp +++ b/include/yacppdic/detail/internal/hash.hpp @@ -4,7 +4,7 @@ constexpr auto GOLDEN_RATIO = 0x9e3779b9; -constexpr std::size_t combine_hashes(std::size_t hash_one, std::size_t hash_two) noexcept +constexpr auto combine_hashes(std::size_t hash_one, std::size_t hash_two) noexcept -> std::size_t { auto combined = hash_one; diff --git a/include/yacppdic/detail/internal/wrapper/function_wrapper-impl.hpp b/include/yacppdic/detail/internal/wrapper/function_wrapper-impl.hpp index fc9492a..f8bf363 100644 --- a/include/yacppdic/detail/internal/wrapper/function_wrapper-impl.hpp +++ b/include/yacppdic/detail/internal/wrapper/function_wrapper-impl.hpp @@ -19,4 +19,4 @@ auto FunctionWrapper<Interface>::get() const noexcept -> Interface return _func; } -} +} // namespace yacppdic::internal diff --git a/include/yacppdic/object_type.hpp b/include/yacppdic/object_type.hpp index b33bb33..1765e65 100644 --- a/include/yacppdic/object_type.hpp +++ b/include/yacppdic/object_type.hpp @@ -13,7 +13,7 @@ public: explicit BaseObjectType( const std::type_info &type_info, - const std::string_view tag + std::string_view tag ) noexcept; auto operator==(const BaseObjectType &object_type) const noexcept -> bool; @@ -35,7 +35,7 @@ class ObjectType : public BaseObjectType public: ObjectType() noexcept : BaseObjectType(typeid(Object)) {} - ObjectType(const std::string_view &tag) noexcept : BaseObjectType(typeid(Object), tag) + explicit ObjectType(const std::string_view &tag) noexcept : BaseObjectType(typeid(Object), tag) { } }; diff --git a/include/yacppdic/tagged.hpp b/include/yacppdic/tagged.hpp index 66c0592..012a46a 100644 --- a/include/yacppdic/tagged.hpp +++ b/include/yacppdic/tagged.hpp @@ -6,6 +6,7 @@ namespace yacppdic { template <typename TargetType, char const *tag> +// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions) class Tagged { public: @@ -15,13 +16,13 @@ public: Tagged(const Tagged &tagged) noexcept = delete; Tagged(Tagged &&tagged) noexcept = delete; - static constexpr char const *get_tag() noexcept + static constexpr auto get_tag() noexcept -> char const * { return tag; } - Tagged &operator=(const Tagged &tagged) noexcept = delete; - Tagged &operator=(Tagged &&tagged) noexcept = delete; + auto operator=(const Tagged &tagged) noexcept -> Tagged & = delete; + auto operator=(Tagged &&tagged) noexcept -> Tagged & = delete; }; template <typename> |