From 80b5ed3d22804aedb968279ec9eaa0819773fb49 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Fri, 17 Sep 2021 23:42:43 +0200 Subject: [PATCH] introduced clang-format (close #733) --- .clang-format | 41 +++++ src/entt/config/config.h | 76 ++++---- src/entt/config/version.h | 2 - src/entt/core/algorithm.hpp | 21 +-- src/entt/core/any.hpp | 96 +++++----- src/entt/core/attribute.h | 43 ++--- src/entt/core/compressed_pair.hpp | 87 ++++----- src/entt/core/enum.hpp | 19 +- src/entt/core/family.hpp | 7 +- src/entt/core/fwd.hpp | 9 +- src/entt/core/hashed_string.hpp | 53 ++---- src/entt/core/ident.hpp | 9 +- src/entt/core/memory.hpp | 12 +- src/entt/core/monostate.hpp | 8 +- src/entt/core/tuple.hpp | 7 +- src/entt/core/type_info.hpp | 51 ++---- src/entt/core/type_traits.hpp | 132 +++----------- src/entt/core/utility.hpp | 35 ++-- src/entt/entity/component.hpp | 12 +- src/entt/entity/entity.hpp | 33 +--- src/entt/entity/fwd.hpp | 36 +--- src/entt/entity/group.hpp | 72 +++----- src/entt/entity/handle.hpp | 31 ++-- src/entt/entity/helper.hpp | 17 +- src/entt/entity/observer.hpp | 31 +--- src/entt/entity/organizer.hpp | 65 +++---- src/entt/entity/poly_storage.hpp | 8 +- src/entt/entity/registry.hpp | 93 +++++----- src/entt/entity/runtime_view.hpp | 34 ++-- src/entt/entity/snapshot.hpp | 52 +++--- src/entt/entity/sparse_set.hpp | 51 ++---- src/entt/entity/storage.hpp | 93 ++++------ src/entt/entity/utility.hpp | 16 +- src/entt/entity/view.hpp | 121 +++++------- src/entt/locator/locator.hpp | 11 +- src/entt/meta/adl_pointer.hpp | 7 +- src/entt/meta/container.hpp | 66 +++---- src/entt/meta/ctx.hpp | 21 +-- src/entt/meta/factory.hpp | 42 ++--- src/entt/meta/fwd.hpp | 13 +- src/entt/meta/meta.hpp | 212 ++++++++-------------- src/entt/meta/node.hpp | 98 ++++------ src/entt/meta/pointer.hpp | 24 +-- src/entt/meta/policy.hpp | 9 +- src/entt/meta/range.hpp | 15 +- src/entt/meta/resolve.hpp | 10 +- src/entt/meta/template.hpp | 8 +- src/entt/meta/type_traits.hpp | 12 +- src/entt/meta/utility.hpp | 90 ++++----- src/entt/platform/android-ndk-r17.hpp | 37 +--- src/entt/poly/fwd.hpp | 8 +- src/entt/poly/poly.hpp | 62 +++---- src/entt/process/process.hpp | 36 ++-- src/entt/process/scheduler.hpp | 26 +-- src/entt/resource/cache.hpp | 19 +- src/entt/resource/fwd.hpp | 8 +- src/entt/resource/handle.hpp | 36 ++-- src/entt/resource/loader.hpp | 9 +- src/entt/signal/delegate.hpp | 53 ++---- src/entt/signal/dispatcher.hpp | 25 +-- src/entt/signal/emitter.hpp | 22 +-- src/entt/signal/fwd.hpp | 12 +- src/entt/signal/sigh.hpp | 41 ++--- test/benchmark/benchmark.cpp | 86 ++++----- test/entt/core/algorithm.cpp | 12 +- test/entt/core/any.cpp | 31 ++-- test/entt/core/compressed_pair.cpp | 20 +- test/entt/core/enum.cpp | 3 +- test/entt/core/memory.cpp | 2 +- test/entt/core/tuple.cpp | 30 +-- test/entt/core/type_info.cpp | 6 +- test/entt/core/type_traits.cpp | 12 +- test/entt/core/utility.cpp | 17 +- test/entt/entity/group.cpp | 10 +- test/entt/entity/handle.cpp | 6 +- test/entt/entity/helper.cpp | 10 +- test/entt/entity/observer.cpp | 14 +- test/entt/entity/poly_storage.cpp | 13 +- test/entt/entity/registry.cpp | 80 ++++---- test/entt/entity/runtime_view.cpp | 26 +-- test/entt/entity/sigh_storage_mixin.cpp | 8 +- test/entt/entity/snapshot.cpp | 81 ++++----- test/entt/entity/sparse_set.cpp | 36 ++-- test/entt/entity/storage.cpp | 53 +++--- test/entt/entity/throwing_allocator.hpp | 13 +- test/entt/entity/throwing_component.hpp | 14 +- test/entt/entity/view.cpp | 10 +- test/entt/locator/locator.cpp | 7 +- test/entt/meta/meta_any.cpp | 29 +-- test/entt/meta/meta_conv.cpp | 4 +- test/entt/meta/meta_ctor.cpp | 24 ++- test/entt/meta/meta_data.cpp | 27 ++- test/entt/meta/meta_func.cpp | 26 ++- test/entt/meta/meta_handle.cpp | 11 +- test/entt/meta/meta_pointer.cpp | 41 +++-- test/entt/meta/meta_type.cpp | 31 ++-- test/entt/poly/poly_deduced.cpp | 61 +++++-- test/entt/poly/poly_defined.cpp | 70 ++++--- test/entt/process/process.cpp | 35 +++- test/entt/process/scheduler.cpp | 18 +- test/entt/resource/resource.cpp | 4 +- test/entt/signal/delegate.cpp | 24 ++- test/entt/signal/dispatcher.cpp | 12 +- test/entt/signal/emitter.cpp | 29 +-- test/entt/signal/sigh.cpp | 49 +++-- test/example/custom_identifier.cpp | 6 +- test/lib/dispatcher/main.cpp | 4 +- test/lib/dispatcher_plugin/main.cpp | 7 +- test/lib/dispatcher_plugin/plugin.cpp | 2 +- test/lib/dispatcher_plugin/type_context.h | 2 +- test/lib/emitter/types.h | 3 +- test/lib/emitter_plugin/main.cpp | 2 +- test/lib/emitter_plugin/plugin.cpp | 2 +- test/lib/emitter_plugin/type_context.h | 2 +- test/lib/emitter_plugin/types.h | 3 +- test/lib/meta/lib.cpp | 16 +- test/lib/meta_plugin/main.cpp | 2 +- test/lib/meta_plugin/plugin.cpp | 18 +- test/lib/meta_plugin_std/main.cpp | 2 +- test/lib/meta_plugin_std/plugin.cpp | 18 +- test/lib/meta_plugin_std/types.h | 9 +- test/lib/registry_plugin/main.cpp | 2 +- test/lib/registry_plugin/plugin.cpp | 2 +- test/lib/registry_plugin/type_context.h | 2 +- test/snapshot/snapshot.cpp | 8 +- 125 files changed, 1536 insertions(+), 2176 deletions(-) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..16d60ef62 --- /dev/null +++ b/.clang-format @@ -0,0 +1,41 @@ +BasedOnStyle: llvm +--- +AccessModifierOffset: -4 +AlignEscapedNewlines: DontAlign +AllowShortBlocksOnASingleLine: Empty +AllowShortEnumsOnASingleLine: true +AllowShortFunctionsOnASingleLine: Empty +AllowShortIfStatementsOnASingleLine: WithoutElse +AllowShortLoopsOnASingleLine: true +AlwaysBreakTemplateDeclarations: Yes +BreakBeforeBinaryOperators: NonAssignment +BreakBeforeTernaryOperators: true +ColumnLimit: 0 +DerivePointerAlignment: false +IncludeCategories: + - Regex: '<[[:alnum:]_]+>' + Priority: 1 + - Regex: '<(gtest|gmock)/' + Priority: 2 + - Regex: '<[[:alnum:]_./]+>' + Priority: 3 + - Regex: '= 201606L -# include -# define ENTT_LAUNDER(expr) std::launder(expr) +# include +# define ENTT_LAUNDER(expr) std::launder(expr) #else -# define ENTT_LAUNDER(expr) expr +# define ENTT_LAUNDER(expr) expr #endif - #ifndef ENTT_USE_ATOMIC -# define ENTT_MAYBE_ATOMIC(Type) Type +# define ENTT_MAYBE_ATOMIC(Type) Type #else -# include -# define ENTT_MAYBE_ATOMIC(Type) std::atomic +# include +# define ENTT_MAYBE_ATOMIC(Type) std::atomic #endif - #ifndef ENTT_ID_TYPE -# include -# define ENTT_ID_TYPE std::uint32_t +# include +# define ENTT_ID_TYPE std::uint32_t #endif - #ifndef ENTT_SPARSE_PAGE -# define ENTT_SPARSE_PAGE 4096 +# define ENTT_SPARSE_PAGE 4096 #endif - #ifndef ENTT_PACKED_PAGE -# define ENTT_PACKED_PAGE 1024 +# define ENTT_PACKED_PAGE 1024 #endif - #ifdef ENTT_DISABLE_ASSERT -# undef ENTT_ASSERT -# define ENTT_ASSERT(...) (void(0)) +# undef ENTT_ASSERT +# define ENTT_ASSERT(...) (void(0)) #elif !defined ENTT_ASSERT -# include -# define ENTT_ASSERT(condition, ...) assert(condition) +# include +# define ENTT_ASSERT(condition, ...) assert(condition) #endif - #ifdef ENTT_NO_ETO -# include -# define ENTT_IGNORE_IF_EMPTY std::false_type +# include +# define ENTT_IGNORE_IF_EMPTY std::false_type #else -# include -# define ENTT_IGNORE_IF_EMPTY std::true_type +# include +# define ENTT_IGNORE_IF_EMPTY std::true_type #endif - #ifndef ENTT_STANDARD_CPP # if defined __clang__ || defined __GNUC__ -# define ENTT_PRETTY_FUNCTION __PRETTY_FUNCTION__ -# define ENTT_PRETTY_FUNCTION_PREFIX '=' -# define ENTT_PRETTY_FUNCTION_SUFFIX ']' +# define ENTT_PRETTY_FUNCTION __PRETTY_FUNCTION__ +# define ENTT_PRETTY_FUNCTION_PREFIX '=' +# define ENTT_PRETTY_FUNCTION_SUFFIX ']' # elif defined _MSC_VER -# define ENTT_PRETTY_FUNCTION __FUNCSIG__ -# define ENTT_PRETTY_FUNCTION_PREFIX '<' -# define ENTT_PRETTY_FUNCTION_SUFFIX '>' -# endif +# define ENTT_PRETTY_FUNCTION __FUNCSIG__ +# define ENTT_PRETTY_FUNCTION_PREFIX '<' +# define ENTT_PRETTY_FUNCTION_SUFFIX '>' +# endif #endif - #endif diff --git a/src/entt/config/version.h b/src/entt/config/version.h index d7e8f8ba1..6212f7b82 100644 --- a/src/entt/config/version.h +++ b/src/entt/config/version.h @@ -1,10 +1,8 @@ #ifndef ENTT_CONFIG_VERSION_H #define ENTT_CONFIG_VERSION_H - #define ENTT_VERSION_MAJOR 3 #define ENTT_VERSION_MINOR 9 #define ENTT_VERSION_PATCH 0 - #endif diff --git a/src/entt/core/algorithm.hpp b/src/entt/core/algorithm.hpp index eda7e8d8b..44c47ef45 100644 --- a/src/entt/core/algorithm.hpp +++ b/src/entt/core/algorithm.hpp @@ -1,18 +1,15 @@ #ifndef ENTT_CORE_ALGORITHM_HPP #define ENTT_CORE_ALGORITHM_HPP - -#include -#include -#include #include #include +#include +#include +#include #include "utility.hpp" - namespace entt { - /** * @brief Function object to wrap `std::sort` in a class type. * @@ -36,12 +33,11 @@ struct std_sort { * @param args Arguments to forward to the sort function, if any. */ template, typename... Args> - void operator()(It first, It last, Compare compare = Compare{}, Args &&... args) const { + void operator()(It first, It last, Compare compare = Compare{}, Args &&...args) const { std::sort(std::forward(args)..., std::move(first), std::move(last), std::move(compare)); } }; - /*! @brief Function object for performing insertion sort. */ struct insertion_sort { /** @@ -62,8 +58,8 @@ struct insertion_sort { auto value = std::move(*it); auto pre = it; - for(; pre > first && compare(value, *(pre-1)); --pre) { - *pre = std::move(*(pre-1)); + for(; pre > first && compare(value, *(pre - 1)); --pre) { + *pre = std::move(*(pre - 1)); } *pre = std::move(value); @@ -72,7 +68,6 @@ struct insertion_sort { } }; - /** * @brief Function object for performing LSD radix sort. * @tparam Bit Number of bits processed per pass. @@ -137,8 +132,6 @@ struct radix_sort { } }; - -} - +} // namespace entt #endif diff --git a/src/entt/core/any.hpp b/src/entt/core/any.hpp index 63450e358..6e9f7649d 100644 --- a/src/entt/core/any.hpp +++ b/src/entt/core/any.hpp @@ -1,7 +1,6 @@ #ifndef ENTT_CORE_ANY_HPP #define ENTT_CORE_ANY_HPP - #include #include #include @@ -12,10 +11,8 @@ #include "type_info.hpp" #include "type_traits.hpp" - namespace entt { - /** * @brief A SBO friendly, type-safe container for single values of any type. * @tparam Len Size of the storage reserved for the small buffer optimization. @@ -23,12 +20,19 @@ namespace entt { */ template class basic_any { - enum class operation: std::uint8_t { - COPY, MOVE, DTOR, COMP, GET, TYPE + enum class operation : std::uint8_t { + COPY, + MOVE, + DTOR, + COMP, + GET, + TYPE }; - enum class policy: std::uint8_t { - OWNER, REF, CREF + enum class policy : std::uint8_t { + OWNER, + REF, + CREF }; using storage_type = std::aligned_storage_t; @@ -38,7 +42,7 @@ class basic_any { static constexpr bool in_situ = Len && alignof(Type) <= alignof(storage_type) && sizeof(Type) <= sizeof(storage_type) && std::is_nothrow_move_constructible_v; template - static const void * basic_vtable([[maybe_unused]] const operation op, [[maybe_unused]] const basic_any &from, [[maybe_unused]] const void *to) { + static const void *basic_vtable([[maybe_unused]] const operation op, [[maybe_unused]] const basic_any &from, [[maybe_unused]] const void *to) { static_assert(!std::is_same_v && std::is_same_v>, Type>, "Invalid type"); const Type *instance = nullptr; @@ -47,7 +51,7 @@ class basic_any { } else { instance = static_cast(from.instance); } - + switch(op) { case operation::COPY: if constexpr(std::is_copy_constructible_v) { @@ -57,10 +61,10 @@ class basic_any { case operation::MOVE: if constexpr(in_situ) { if(from.mode == policy::OWNER) { - return new (&static_cast(const_cast(to))->storage) Type{std::move(*const_cast(instance))}; + return new(&static_cast(const_cast(to))->storage) Type{std::move(*const_cast(instance))}; } } - + return (static_cast(const_cast(to))->instance = std::exchange(const_cast(from).instance, nullptr)); case operation::DTOR: if constexpr(in_situ) { @@ -71,8 +75,7 @@ class basic_any { delete instance; } break; - case operation::COMP: - { + case operation::COMP: { const auto info = type_id(); auto *value = static_cast(to)->data(&info); @@ -93,7 +96,7 @@ class basic_any { } template - void initialize([[maybe_unused]] Args &&... args) { + void initialize([[maybe_unused]] Args &&...args) { if constexpr(!std::is_void_v) { vtable = basic_vtable>>; @@ -103,9 +106,9 @@ class basic_any { instance = (std::addressof(args), ...); } else if constexpr(in_situ) { if constexpr(sizeof...(Args) != 0u && std::is_aggregate_v) { - new (&storage) Type{std::forward(args)...}; + new(&storage) Type{std::forward(args)...}; } else { - new (&storage) Type(std::forward(args)...); + new(&storage) Type(std::forward(args)...); } } else { if constexpr(sizeof...(Args) != 0u && std::is_aggregate_v) { @@ -120,8 +123,7 @@ class basic_any { basic_any(const basic_any &other, const policy pol) ENTT_NOEXCEPT : instance{other.data()}, vtable{other.vtable}, - mode{pol} - {} + mode{pol} {} public: /*! @brief Size of the internal storage. */ @@ -133,8 +135,7 @@ public: basic_any() ENTT_NOEXCEPT : instance{}, vtable{}, - mode{policy::OWNER} - {} + mode{policy::OWNER} {} /** * @brief Constructs a wrapper by directly initializing the new object. @@ -143,9 +144,8 @@ public: * @param args Parameters to use to construct the instance. */ template - explicit basic_any(std::in_place_type_t, Args &&... args) - : basic_any{} - { + explicit basic_any(std::in_place_type_t, Args &&...args) + : basic_any{} { initialize(std::forward(args)...); } @@ -156,8 +156,7 @@ public: */ template, basic_any>>> basic_any(Type &&value) - : basic_any{} - { + : basic_any{} { initialize>(std::forward(value)); } @@ -166,8 +165,7 @@ public: * @param other The instance to copy from. */ basic_any(const basic_any &other) - : basic_any{} - { + : basic_any{} { if(other.vtable) { other.vtable(operation::COPY, other, this); } @@ -180,8 +178,7 @@ public: basic_any(basic_any &&other) ENTT_NOEXCEPT : instance{}, vtable{other.vtable}, - mode{other.mode} - { + mode{other.mode} { if(other.vtable) { other.vtable(operation::MOVE, other, this); } @@ -199,7 +196,7 @@ public: * @param other The instance to copy from. * @return This any object. */ - basic_any & operator=(const basic_any &other) { + basic_any &operator=(const basic_any &other) { reset(); if(other.vtable) { @@ -214,7 +211,7 @@ public: * @param other The instance to move from. * @return This any object. */ - basic_any & operator=(basic_any &&other) ENTT_NOEXCEPT { + basic_any &operator=(basic_any &&other) ENTT_NOEXCEPT { reset(); if(other.vtable) { @@ -258,12 +255,12 @@ public: * @param req Optional expected type. * @return An opaque pointer the contained instance, if any. */ - [[nodiscard]] const void * data(const type_info *req = nullptr) const ENTT_NOEXCEPT { + [[nodiscard]] const void *data(const type_info *req = nullptr) const ENTT_NOEXCEPT { return vtable ? vtable(operation::GET, *this, req) : nullptr; } /*! @copydoc data */ - [[nodiscard]] void * data(const type_info *req = nullptr) ENTT_NOEXCEPT { + [[nodiscard]] void *data(const type_info *req = nullptr) ENTT_NOEXCEPT { return (!vtable || mode == policy::CREF) ? nullptr : const_cast(vtable(operation::GET, *this, req)); } @@ -274,7 +271,7 @@ public: * @param args Parameters to use to construct the instance. */ template - void emplace(Args &&... args) { + void emplace(Args &&...args) { reset(); initialize(std::forward(args)...); } @@ -332,12 +329,14 @@ public: } private: - union { const void *instance; storage_type storage; }; + union { + const void *instance; + storage_type storage; + }; vtable_type *vtable; policy mode; }; - /** * @brief Checks if two wrappers differ in their content. * @tparam Len Size of the storage reserved for the small buffer optimization. @@ -351,7 +350,6 @@ template return !(lhs == rhs); } - /** * @brief Performs type-safe access to the contained object. * @tparam Type Type to which conversion is required. @@ -362,56 +360,51 @@ template */ template Type any_cast(const basic_any &data) ENTT_NOEXCEPT { - const auto * const instance = any_cast>(&data); + const auto *const instance = any_cast>(&data); ENTT_ASSERT(instance, "Invalid instance"); return static_cast(*instance); } - /*! @copydoc any_cast */ template Type any_cast(basic_any &data) ENTT_NOEXCEPT { // forces const on non-reference types to make them work also with wrappers for const references - auto * const instance = any_cast>(&data); + auto *const instance = any_cast>(&data); ENTT_ASSERT(instance, "Invalid instance"); return static_cast(*instance); } - /*! @copydoc any_cast */ template Type any_cast(basic_any &&data) ENTT_NOEXCEPT { if constexpr(std::is_copy_constructible_v>>) { - if(auto * const instance = any_cast>(&data); instance) { + if(auto *const instance = any_cast>(&data); instance) { return static_cast(std::move(*instance)); } else { return any_cast(data); } } else { - auto * const instance = any_cast>(&data); + auto *const instance = any_cast>(&data); ENTT_ASSERT(instance, "Invalid instance"); return static_cast(std::move(*instance)); } } - /*! @copydoc any_cast */ template -const Type * any_cast(const basic_any *data) ENTT_NOEXCEPT { +const Type *any_cast(const basic_any *data) ENTT_NOEXCEPT { const auto info = type_id>>(); return static_cast(data->data(&info)); } - /*! @copydoc any_cast */ template -Type * any_cast(basic_any *data) ENTT_NOEXCEPT { +Type *any_cast(basic_any *data) ENTT_NOEXCEPT { const auto info = type_id>>(); // last attempt to make wrappers for const references return their values return static_cast(static_cast, Type> *>(data)->data(&info)); } - /** * @brief Constructs a wrapper from a given type, passing it all arguments. * @tparam Type Type of object to use to initialize the wrapper. @@ -422,11 +415,10 @@ Type * any_cast(basic_any *data) ENTT_NOEXCEPT { * @return A properly initialized wrapper for an object of the given type. */ template::length, std::size_t Align = basic_any::alignment, typename... Args> -basic_any make_any(Args &&... args) { +basic_any make_any(Args &&...args) { return basic_any{std::in_place_type, std::forward(args)...}; } - /** * @brief Forwards its argument and avoids copies for lvalue references. * @tparam Len Size of the storage reserved for the small buffer optimization. @@ -440,8 +432,6 @@ basic_any forward_as_any(Type &&value) { return basic_any{std::in_place_type, std::decay_t, Type>>, std::forward(value)}; } - -} - +} // namespace entt #endif diff --git a/src/entt/core/attribute.h b/src/entt/core/attribute.h index 4a7a09268..b1d0503be 100644 --- a/src/entt/core/attribute.h +++ b/src/entt/core/attribute.h @@ -1,33 +1,30 @@ #ifndef ENTT_CORE_ATTRIBUTE_H #define ENTT_CORE_ATTRIBUTE_H - #ifndef ENTT_EXPORT -# if defined _WIN32 || defined __CYGWIN__ || defined _MSC_VER -# define ENTT_EXPORT __declspec(dllexport) -# define ENTT_IMPORT __declspec(dllimport) -# define ENTT_HIDDEN -# elif defined __GNUC__ && __GNUC__ >= 4 -# define ENTT_EXPORT __attribute__((visibility("default"))) -# define ENTT_IMPORT __attribute__((visibility("default"))) -# define ENTT_HIDDEN __attribute__((visibility("hidden"))) -# else /* Unsupported compiler */ -# define ENTT_EXPORT -# define ENTT_IMPORT -# define ENTT_HIDDEN -# endif +# if defined _WIN32 || defined __CYGWIN__ || defined _MSC_VER +# define ENTT_EXPORT __declspec(dllexport) +# define ENTT_IMPORT __declspec(dllimport) +# define ENTT_HIDDEN +# elif defined __GNUC__ && __GNUC__ >= 4 +# define ENTT_EXPORT __attribute__((visibility("default"))) +# define ENTT_IMPORT __attribute__((visibility("default"))) +# define ENTT_HIDDEN __attribute__((visibility("hidden"))) +# else /* Unsupported compiler */ +# define ENTT_EXPORT +# define ENTT_IMPORT +# define ENTT_HIDDEN +# endif #endif - #ifndef ENTT_API -# if defined ENTT_API_EXPORT -# define ENTT_API ENTT_EXPORT -# elif defined ENTT_API_IMPORT -# define ENTT_API ENTT_IMPORT -# else /* No API */ -# define ENTT_API -# endif +# if defined ENTT_API_EXPORT +# define ENTT_API ENTT_EXPORT +# elif defined ENTT_API_IMPORT +# define ENTT_API ENTT_IMPORT +# else /* No API */ +# define ENTT_API +# endif #endif - #endif diff --git a/src/entt/core/compressed_pair.hpp b/src/entt/core/compressed_pair.hpp index 533ff167c..9fda3ea00 100644 --- a/src/entt/core/compressed_pair.hpp +++ b/src/entt/core/compressed_pair.hpp @@ -1,7 +1,6 @@ #ifndef ENTT_CORE_COMPRESSED_PAIR_HPP #define ENTT_CORE_COMPRESSED_PAIR_HPP - #include #include #include @@ -9,41 +8,34 @@ #include "../config/config.h" #include "type_traits.hpp" - namespace entt { - /** * @cond TURN_OFF_DOXYGEN * Internal details not to be documented. */ - namespace internal { - template struct compressed_pair_element { template>> compressed_pair_element() - : value{} - {} + : value{} {} template, compressed_pair_element>>> compressed_pair_element(Args &&args) - : value{std::forward(args)} - {} + : value{std::forward(args)} {} template compressed_pair_element(std::tuple args, std::index_sequence) - : value{std::get(args)...} - {} + : value{std::get(args)...} {} - [[nodiscard]] Type & get() ENTT_NOEXCEPT { + [[nodiscard]] Type &get() ENTT_NOEXCEPT { return value; } - [[nodiscard]] const Type & get() const ENTT_NOEXCEPT { + [[nodiscard]] const Type &get() const ENTT_NOEXCEPT { return value; } @@ -51,43 +43,36 @@ private: Type value; }; - template struct compressed_pair_element>>: Type { template>> compressed_pair_element() - : Type{} - {} + : Type{} {} template, compressed_pair_element>>> compressed_pair_element(Args &&args) - : Type{std::forward(args)} - {} + : Type{std::forward(args)} {} template compressed_pair_element(std::tuple args, std::index_sequence) - : Type{std::get(args)...} - {} + : Type{std::get(args)...} {} - [[nodiscard]] Type & get() ENTT_NOEXCEPT { + [[nodiscard]] Type &get() ENTT_NOEXCEPT { return *this; } - [[nodiscard]] const Type & get() const ENTT_NOEXCEPT { + [[nodiscard]] const Type &get() const ENTT_NOEXCEPT { return *this; } }; - -} - +} // namespace internal /** * Internal details not to be documented. * @endcond */ - /** * @brief A compressed pair. * @@ -99,8 +84,8 @@ struct compressed_pair_element class compressed_pair final - : internal::compressed_pair_element, internal::compressed_pair_element -{ + : internal::compressed_pair_element, + internal::compressed_pair_element { using first_base = internal::compressed_pair_element; using second_base = internal::compressed_pair_element; @@ -116,8 +101,7 @@ public: template && std::is_default_constructible_v>> constexpr compressed_pair() : first_base{}, - second_base{} - {} + second_base{} {} /** * @brief Copy constructor. @@ -141,8 +125,7 @@ public: template constexpr compressed_pair(Arg &&arg, Other &&other) : first_base{std::forward(arg)}, - second_base{std::forward(other)} - {} + second_base{std::forward(other)} {} /** * @brief Constructs a pair by forwarding the arguments to its parts. @@ -154,33 +137,32 @@ public: template constexpr compressed_pair(std::piecewise_construct_t, std::tuple args, std::tuple other) : first_base{std::move(args), std::index_sequence_for{}}, - second_base{std::move(other), std::index_sequence_for{}} - {} + second_base{std::move(other), std::index_sequence_for{}} {} /** * @brief Copy assignment operator. * @param other The instance to copy from. * @return This compressed pair object. */ - constexpr compressed_pair & operator=(const compressed_pair &other) = default; + constexpr compressed_pair &operator=(const compressed_pair &other) = default; /** * @brief Move assignment operator. * @param other The instance to move from. * @return This compressed pair object. */ - constexpr compressed_pair & operator=(compressed_pair &&other) ENTT_NOEXCEPT = default; + constexpr compressed_pair &operator=(compressed_pair &&other) ENTT_NOEXCEPT = default; /** * @brief Returns the first element that a pair stores. * @return The first element that a pair stores. */ - [[nodiscard]] First & first() ENTT_NOEXCEPT { + [[nodiscard]] First &first() ENTT_NOEXCEPT { return static_cast(*this).get(); } /*! @copydoc first */ - [[nodiscard]] const First & first() const ENTT_NOEXCEPT { + [[nodiscard]] const First &first() const ENTT_NOEXCEPT { return static_cast(*this).get(); } @@ -188,12 +170,12 @@ public: * @brief Returns the second element that a pair stores. * @return The second element that a pair stores. */ - [[nodiscard]] Second & second() ENTT_NOEXCEPT { + [[nodiscard]] Second &second() ENTT_NOEXCEPT { return static_cast(*this).get(); } /*! @copydoc second */ - [[nodiscard]] const Second & second() const ENTT_NOEXCEPT { + [[nodiscard]] const Second &second() const ENTT_NOEXCEPT { return static_cast(*this).get(); } @@ -235,7 +217,6 @@ public: } }; - /** * @brief Deduction guide. * @tparam Type Type of value to use to initialize the first element. @@ -244,7 +225,6 @@ public: template compressed_pair(Type &&, Other &&) -> compressed_pair, std::decay_t>; - /** * @brief Swaps two compressed pair objects. * @tparam First The type of the first element that the pairs store. @@ -257,22 +237,21 @@ inline void swap(compressed_pair &lhs, compressed_pair 6 - template - struct tuple_size>: integral_constant {}; +namespace std { - template - struct tuple_element>: conditional { - static_assert(Index < 2u, "Index out of bounds"); - }; +template +struct tuple_size>: integral_constant {}; + +template +struct tuple_element>: conditional { + static_assert(Index < 2u, "Index out of bounds"); +}; + +} // namespace std #endif -} - #endif diff --git a/src/entt/core/enum.hpp b/src/entt/core/enum.hpp index 4f726977a..359f9436f 100644 --- a/src/entt/core/enum.hpp +++ b/src/entt/core/enum.hpp @@ -1,14 +1,11 @@ #ifndef ENTT_CORE_FLAG_HPP #define ENTT_CORE_FLAG_HPP - #include #include "../config/config.h" - namespace entt { - /** * @brief Enable bitmask support for enum classes. * @tparam Type The enum type for which to enable bitmask support. @@ -16,12 +13,10 @@ namespace entt { template struct enum_as_bitmask: std::false_type {}; - /*! @copydoc enum_as_bitmask */ template struct enum_as_bitmask>: std::true_type {}; - /** * @brief Helper variable template. * @tparam Type The enum class type for which to enable bitmask support. @@ -29,9 +24,7 @@ struct enum_as_bitmask> template inline constexpr bool enum_as_bitmask_v = enum_as_bitmask::value; - -} - +} // namespace entt /** * @brief Operator available for enums for which bitmask support is enabled. @@ -47,7 +40,6 @@ operator|(const Type lhs, const Type rhs) ENTT_NOEXCEPT { return Type{static_cast>(lhs) | static_cast>(rhs)}; } - /*! @copydoc operator| */ template [[nodiscard]] constexpr std::enable_if_t && entt::enum_as_bitmask_v, Type> @@ -55,7 +47,6 @@ operator&(const Type lhs, const Type rhs) ENTT_NOEXCEPT { return Type{static_cast>(lhs) & static_cast>(rhs)}; } - /*! @copydoc operator| */ template [[nodiscard]] constexpr std::enable_if_t && entt::enum_as_bitmask_v, Type> @@ -63,7 +54,6 @@ operator^(const Type lhs, const Type rhs) ENTT_NOEXCEPT { return Type{static_cast>(lhs) ^ static_cast>(rhs)}; } - /** * @brief Operator available for enums for which bitmask support is enabled. * @tparam Type Enum class type. @@ -77,7 +67,6 @@ operator~(const Type value) ENTT_NOEXCEPT { return Type{~static_cast>(value)}; } - /*! @copydoc operator~ */ template [[nodiscard]] constexpr std::enable_if_t && entt::enum_as_bitmask_v, bool> @@ -85,7 +74,6 @@ operator!(const Type value) ENTT_NOEXCEPT { return !static_cast>(value); } - /*! @copydoc operator| */ template constexpr std::enable_if_t && entt::enum_as_bitmask_v, Type &> @@ -93,7 +81,6 @@ operator|=(Type &lhs, const Type rhs) ENTT_NOEXCEPT { return (lhs = (lhs | rhs)); } - /*! @copydoc operator| */ template constexpr std::enable_if_t && entt::enum_as_bitmask_v, Type &> @@ -101,7 +88,6 @@ operator&=(Type &lhs, const Type rhs) ENTT_NOEXCEPT { return (lhs = (lhs & rhs)); } - /*! @copydoc operator| */ template constexpr std::enable_if_t && entt::enum_as_bitmask_v, Type &> @@ -109,7 +95,6 @@ operator^=(Type &lhs, const Type rhs) ENTT_NOEXCEPT { return (lhs = (lhs ^ rhs)); } - /*! @copydoc operator| */ template [[nodiscard]] constexpr std::enable_if_t && entt::enum_as_bitmask_v, Type> @@ -117,7 +102,6 @@ operator==(const Type lhs, const Type rhs) ENTT_NOEXCEPT { return (static_cast>(lhs) == static_cast>(rhs)); } - /*! @copydoc operator| */ template [[nodiscard]] constexpr std::enable_if_t && entt::enum_as_bitmask_v, Type> @@ -125,5 +109,4 @@ operator!=(const Type lhs, const Type rhs) ENTT_NOEXCEPT { return !(lhs == rhs); } - #endif diff --git a/src/entt/core/family.hpp b/src/entt/core/family.hpp index de0a8ce7c..4df1ec0b0 100644 --- a/src/entt/core/family.hpp +++ b/src/entt/core/family.hpp @@ -1,14 +1,11 @@ #ifndef ENTT_CORE_FAMILY_HPP #define ENTT_CORE_FAMILY_HPP - #include "../config/config.h" #include "fwd.hpp" - namespace entt { - /** * @brief Dynamic identifier generator. * @@ -30,8 +27,6 @@ public: inline static const family_type type = identifier++; }; - -} - +} // namespace entt #endif diff --git a/src/entt/core/fwd.hpp b/src/entt/core/fwd.hpp index 193aad86a..8e1ed5828 100644 --- a/src/entt/core/fwd.hpp +++ b/src/entt/core/fwd.hpp @@ -1,27 +1,20 @@ #ifndef ENTT_CORE_FWD_HPP #define ENTT_CORE_FWD_HPP - #include #include "../config/config.h" - namespace entt { - template)> class basic_any; - /*! @brief Alias declaration for type identifiers. */ using id_type = ENTT_ID_TYPE; - /*! @brief Alias declaration for the most common use case. */ using any = basic_any<>; - -} - +} // namespace entt #endif diff --git a/src/entt/core/hashed_string.hpp b/src/entt/core/hashed_string.hpp index f7cb24ebb..76fd20e3f 100644 --- a/src/entt/core/hashed_string.hpp +++ b/src/entt/core/hashed_string.hpp @@ -1,29 +1,23 @@ #ifndef ENTT_CORE_HASHED_STRING_HPP #define ENTT_CORE_HASHED_STRING_HPP - #include #include #include "../config/config.h" #include "fwd.hpp" - namespace entt { - /** * @cond TURN_OFF_DOXYGEN * Internal details not to be documented. */ - namespace internal { - template struct fnv1a_traits; - template<> struct fnv1a_traits { using type = std::uint32_t; @@ -31,7 +25,6 @@ struct fnv1a_traits { static constexpr std::uint32_t prime = 16777619; }; - template<> struct fnv1a_traits { using type = std::uint64_t; @@ -39,16 +32,13 @@ struct fnv1a_traits { static constexpr std::uint64_t prime = 1099511628211ull; }; - -} - +} // namespace internal /** * Internal details not to be documented. * @endcond */ - /** * @brief Zero overhead unique identifier. * @@ -130,8 +120,8 @@ public: /*! @brief Constructs an empty hashed string. */ constexpr basic_hashed_string() ENTT_NOEXCEPT - : str{nullptr}, hash{} - {} + : str{nullptr}, + hash{} {} /** * @brief Constructs a hashed string from an array of const characters. @@ -149,8 +139,8 @@ public: */ template constexpr basic_hashed_string(const value_type (&curr)[N]) ENTT_NOEXCEPT - : str{curr}, hash{helper(curr)} - {} + : str{curr}, + hash{helper(curr)} {} /** * @brief Explicit constructor on purpose to avoid constructing a hashed @@ -158,14 +148,14 @@ public: * @param wrapper Helps achieving the purpose by relying on overloading. */ explicit constexpr basic_hashed_string(const_wrapper wrapper) ENTT_NOEXCEPT - : str{wrapper.str}, hash{helper(wrapper.str)} - {} + : str{wrapper.str}, + hash{helper(wrapper.str)} {} /** * @brief Returns the human-readable representation of a hashed string. * @return The string used to initialize the instance. */ - [[nodiscard]] constexpr const value_type * data() const ENTT_NOEXCEPT { + [[nodiscard]] constexpr const value_type *data() const ENTT_NOEXCEPT { return str; } @@ -178,20 +168,23 @@ public: } /*! @copydoc data */ - [[nodiscard]] constexpr operator const value_type *() const ENTT_NOEXCEPT { return data(); } + [[nodiscard]] constexpr operator const value_type *() const ENTT_NOEXCEPT { + return data(); + } /** * @brief Returns the numeric representation of a hashed string. * @return The numeric representation of the instance. */ - [[nodiscard]] constexpr operator hash_type() const ENTT_NOEXCEPT { return value(); } + [[nodiscard]] constexpr operator hash_type() const ENTT_NOEXCEPT { + return value(); + } private: const value_type *str; hash_type hash; }; - /** * @brief Deduction guide. * @@ -205,7 +198,6 @@ private: template basic_hashed_string(const Char (&str)[N]) -> basic_hashed_string; - /** * @brief Compares two hashed strings. * @tparam Char Character type. @@ -218,7 +210,6 @@ template return lhs.value() == rhs.value(); } - /** * @brief Compares two hashed strings. * @tparam Char Character type. @@ -231,7 +222,6 @@ template return !(lhs == rhs); } - /** * @brief Compares two hashed strings. * @tparam Char Character type. @@ -244,7 +234,6 @@ template return lhs.value() < rhs.value(); } - /** * @brief Compares two hashed strings. * @tparam Char Character type. @@ -258,7 +247,6 @@ template return lhs.value() <= rhs.value(); } - /** * @brief Compares two hashed strings. * @tparam Char Character type. @@ -272,7 +260,6 @@ template return !(lhs <= rhs); } - /** * @brief Compares two hashed strings. * @tparam Char Character type. @@ -286,18 +273,14 @@ template return !(lhs < rhs); } - /*! @brief Aliases for common character types. */ using hashed_string = basic_hashed_string; - /*! @brief Aliases for common character types. */ using hashed_wstring = basic_hashed_string; - inline namespace literals { - /** * @brief User defined literal for hashed strings. * @param str The literal without its suffix. @@ -307,7 +290,6 @@ inline namespace literals { return entt::hashed_string{str}; } - /** * @brief User defined literal for hashed wstrings. * @param str The literal without its suffix. @@ -317,11 +299,8 @@ inline namespace literals { return entt::hashed_wstring{str}; } +} // namespace literals -} - - -} - +} // namespace entt #endif diff --git a/src/entt/core/ident.hpp b/src/entt/core/ident.hpp index 9b89d5255..5c3a6330d 100644 --- a/src/entt/core/ident.hpp +++ b/src/entt/core/ident.hpp @@ -1,18 +1,15 @@ #ifndef ENTT_CORE_IDENT_HPP #define ENTT_CORE_IDENT_HPP - #include -#include #include +#include #include "../config/config.h" #include "fwd.hpp" #include "type_traits.hpp" - namespace entt { - /** * @brief Types identifiers. * @@ -57,8 +54,6 @@ public: static constexpr identifier_type type = get>(std::index_sequence_for{}); }; - -} - +} // namespace entt #endif diff --git a/src/entt/core/memory.hpp b/src/entt/core/memory.hpp index 2bb91d429..d57e7a89a 100644 --- a/src/entt/core/memory.hpp +++ b/src/entt/core/memory.hpp @@ -1,17 +1,14 @@ #ifndef ENTT_CORE_MEMORY_HPP #define ENTT_CORE_MEMORY_HPP - #include #include #include #include #include "../config/config.h" - namespace entt { - /** * @brief Unwraps fancy pointers, does nothing otherwise (waiting for C++20). * @tparam Type Pointer type. @@ -27,7 +24,6 @@ template } } - /** * @brief Utility function to design allocation-aware containers. * @tparam Allocator Type of allocator. @@ -41,7 +37,6 @@ constexpr void propagate_on_container_copy_assignment([[maybe_unused]] Allocator } } - /** * @brief Utility function to design allocation-aware containers. * @tparam Allocator Type of allocator. @@ -55,7 +50,6 @@ constexpr void propagate_on_container_move_assignment([[maybe_unused]] Allocator } } - /** * @brief Utility function to design allocation-aware containers. * @tparam Allocator Type of allocator. @@ -73,7 +67,6 @@ constexpr void propagate_on_container_swap(Allocator &lhs, Allocator &rhs) ENTT_ } } - /** * @brief Checks whether a value is a power of two or not. * @param value A value that may or may not be a power of two. @@ -83,7 +76,6 @@ constexpr void propagate_on_container_swap(Allocator &lhs, Allocator &rhs) ENTT_ return value && ((value & (value - 1)) == 0); } - /** * @brief Fast module utility function (powers of two only). * @tparam Value Compile-time page size, it must be a power of two. @@ -96,8 +88,6 @@ template return value & (Value - 1u); } - -} - +} // namespace entt #endif diff --git a/src/entt/core/monostate.hpp b/src/entt/core/monostate.hpp index e25dd5313..1b08a0a6a 100644 --- a/src/entt/core/monostate.hpp +++ b/src/entt/core/monostate.hpp @@ -1,14 +1,11 @@ #ifndef ENTT_CORE_MONOSTATE_HPP #define ENTT_CORE_MONOSTATE_HPP - #include "../config/config.h" #include "fwd.hpp" - namespace entt { - /** * @brief Minimal implementation of the monostate pattern. * @@ -47,7 +44,6 @@ private: inline static ENTT_MAYBE_ATOMIC(Type) value{}; }; - /** * @brief Helper variable template. * @tparam Value Value used to differentiate between different variables. @@ -55,8 +51,6 @@ private: template inline monostate monostate_v = {}; - -} - +} // namespace entt #endif diff --git a/src/entt/core/tuple.hpp b/src/entt/core/tuple.hpp index 3bd8c0f57..4338b29b8 100644 --- a/src/entt/core/tuple.hpp +++ b/src/entt/core/tuple.hpp @@ -1,16 +1,13 @@ #ifndef ENTT_CORE_TUPLE_HPP #define ENTT_CORE_TUPLE_HPP - #include #include #include #include "../config/config.h" - namespace entt { - /** * @brief Utility function to unwrap tuples of a single element. * @tparam Type Tuple type of any sizes. @@ -27,8 +24,6 @@ constexpr decltype(auto) unwrap_tuple(Type &&value) ENTT_NOEXCEPT { } } - -} - +} // namespace entt #endif diff --git a/src/entt/core/type_info.hpp b/src/entt/core/type_info.hpp index 6b0c73351..16df97bca 100644 --- a/src/entt/core/type_info.hpp +++ b/src/entt/core/type_info.hpp @@ -1,28 +1,23 @@ #ifndef ENTT_CORE_TYPE_INFO_HPP #define ENTT_CORE_TYPE_INFO_HPP - #include #include #include #include "../config/config.h" #include "../core/attribute.h" -#include "hashed_string.hpp" #include "fwd.hpp" - +#include "hashed_string.hpp" namespace entt { - /** * @cond TURN_OFF_DOXYGEN * Internal details not to be documented. */ - namespace internal { - struct ENTT_API type_index final { [[nodiscard]] static id_type next() ENTT_NOEXCEPT { static ENTT_MAYBE_ATOMIC(id_type) value{}; @@ -30,12 +25,11 @@ struct ENTT_API type_index final { } }; - template [[nodiscard]] constexpr auto stripped_type_name() ENTT_NOEXCEPT { #if defined ENTT_PRETTY_FUNCTION std::string_view pretty_function{ENTT_PRETTY_FUNCTION}; - auto first = pretty_function.find_first_not_of(' ', pretty_function.find_first_of(ENTT_PRETTY_FUNCTION_PREFIX)+1); + auto first = pretty_function.find_first_not_of(' ', pretty_function.find_first_of(ENTT_PRETTY_FUNCTION_PREFIX) + 1); auto value = pretty_function.substr(first, pretty_function.find_last_of(ENTT_PRETTY_FUNCTION_SUFFIX) - first); return value; #else @@ -43,21 +37,18 @@ template #endif } - template().find_first_of('.')> [[nodiscard]] static constexpr std::string_view type_name(int) ENTT_NOEXCEPT { constexpr auto value = stripped_type_name(); return value; } - template [[nodiscard]] static std::string_view type_name(char) ENTT_NOEXCEPT { static const auto value = stripped_type_name(); return value; } - template().find_first_of('.')> [[nodiscard]] static constexpr id_type type_hash(int) ENTT_NOEXCEPT { constexpr auto stripped = stripped_type_name(); @@ -65,7 +56,6 @@ template().find_first_of('.')> return value; } - template [[nodiscard]] static id_type type_hash(char) ENTT_NOEXCEPT { static const auto value = [](const auto stripped) { @@ -74,16 +64,13 @@ template return value; } - -} - +} // namespace internal /** * Internal details not to be documented. * @endcond */ - /** * @brief Type sequential identifier. * @tparam Type Type for which to generate a sequential identifier. @@ -100,10 +87,11 @@ struct ENTT_API type_index final { } /*! @copydoc value */ - [[nodiscard]] constexpr operator id_type() const ENTT_NOEXCEPT { return value(); } + [[nodiscard]] constexpr operator id_type() const ENTT_NOEXCEPT { + return value(); + } }; - /** * @brief Type hash. * @tparam Type Type for which to generate a hash value. @@ -124,10 +112,11 @@ struct type_hash final { } /*! @copydoc value */ - [[nodiscard]] constexpr operator id_type() const ENTT_NOEXCEPT { return value(); } + [[nodiscard]] constexpr operator id_type() const ENTT_NOEXCEPT { + return value(); + } }; - /** * @brief Type name. * @tparam Type Type for which to generate a name. @@ -143,18 +132,18 @@ struct type_name final { } /*! @copydoc value */ - [[nodiscard]] constexpr operator std::string_view() const ENTT_NOEXCEPT { return value(); } + [[nodiscard]] constexpr operator std::string_view() const ENTT_NOEXCEPT { + return value(); + } }; - /*! @brief Implementation specific information about a type. */ struct type_info final { /*! @brief Default constructor. */ constexpr type_info() ENTT_NOEXCEPT : seq{}, identifier{}, - alias{} - {} + alias{} {} /*! @brief Default copy constructor. */ constexpr type_info(const type_info &) ENTT_NOEXCEPT = default; @@ -169,20 +158,19 @@ struct type_info final { constexpr type_info(std::in_place_type_t) ENTT_NOEXCEPT : seq{type_index>>::value()}, identifier{type_hash>>::value()}, - alias{type_name>>::value()} - {} + alias{type_name>>::value()} {} /** * @brief Default copy assignment operator. * @return This type info object. */ - constexpr type_info & operator=(const type_info &) ENTT_NOEXCEPT = default; + constexpr type_info &operator=(const type_info &) ENTT_NOEXCEPT = default; /** * @brief Default move assignment operator. * @return This type info object. */ - constexpr type_info & operator=(type_info &&) ENTT_NOEXCEPT = default; + constexpr type_info &operator=(type_info &&) ENTT_NOEXCEPT = default; /** * @brief Checks if a type info object is properly initialized. @@ -222,7 +210,6 @@ private: std::string_view alias; }; - /** * @brief Compares the contents of two type info objects. * @param lhs A type info object. @@ -233,7 +220,6 @@ private: return lhs.hash() == rhs.hash(); } - /** * @brief Compares the contents of two type info objects. * @param lhs A type info object. @@ -244,7 +230,6 @@ private: return !(lhs == rhs); } - /** * @brief Returns the type info object associated to a given type. * @@ -260,8 +245,6 @@ template return type_info{std::in_place_type>>}; } - -} - +} // namespace entt #endif diff --git a/src/entt/core/type_traits.hpp b/src/entt/core/type_traits.hpp index 0bf2ca4bf..c961e80f7 100644 --- a/src/entt/core/type_traits.hpp +++ b/src/entt/core/type_traits.hpp @@ -1,7 +1,6 @@ #ifndef ENTT_CORE_TYPE_TRAITS_HPP #define ENTT_CORE_TYPE_TRAITS_HPP - #include #include #include @@ -9,10 +8,8 @@ #include "../config/config.h" #include "fwd.hpp" - namespace entt { - /** * @brief Utility class to disambiguate overloaded functions. * @tparam N Number of choices available. @@ -23,12 +20,10 @@ struct choice_t : /*! @cond TURN_OFF_DOXYGEN */ choice_t /*! @endcond */ {}; - /*! @copybrief choice_t */ template<> struct choice_t<0> {}; - /** * @brief Variable template for the choice trick. * @tparam N Number of choices available. @@ -36,7 +31,6 @@ struct choice_t<0> {}; template inline constexpr choice_t choice{}; - /** * @brief Identity type trait. * @@ -51,7 +45,6 @@ struct type_identity { using type = Type; }; - /** * @brief Helper type. * @tparam Type A type. @@ -59,7 +52,6 @@ struct type_identity { template using type_identity_t = typename type_identity::type; - /** * @brief A type-only `sizeof` wrapper that returns 0 where `sizeof` complains. * @tparam Type The type of which to return the size. @@ -68,13 +60,10 @@ using type_identity_t = typename type_identity::type; template struct size_of: std::integral_constant {}; - /*! @copydoc size_of */ template struct size_of> - : std::integral_constant -{}; - + : std::integral_constant {}; /** * @brief Helper variable template. @@ -83,7 +72,6 @@ struct size_of> template inline constexpr std::size_t size_of_v = size_of::value; - /** * @brief Using declaration to be used to _repeat_ the same type a number of * times equal to the size of a given parameter pack. @@ -92,7 +80,6 @@ inline constexpr std::size_t size_of_v = size_of::value; template using unpack_as_t = Type; - /** * @brief Helper variable template to be used to _repeat_ the same value a * number of times equal to the size of a given parameter pack. @@ -101,7 +88,6 @@ using unpack_as_t = Type; template inline constexpr auto unpack_as_v = Value; - /** * @brief Wraps a static constant. * @tparam Value A static constant. @@ -109,7 +95,6 @@ inline constexpr auto unpack_as_v = Value; template using integral_constant = std::integral_constant; - /** * @brief Alias template to facilitate the creation of named values. * @tparam Value A constant value at least convertible to `id_type`. @@ -117,7 +102,6 @@ using integral_constant = std::integral_constant; template using tag = integral_constant; - /** * @brief A class to use to push around lists of types, nothing more. * @tparam Type Types provided by the type list. @@ -130,12 +114,10 @@ struct type_list { static constexpr auto size = sizeof...(Type); }; - /*! @brief Primary template isn't defined on purpose. */ template struct type_list_element; - /** * @brief Provides compile-time indexed access to the types of a type list. * @tparam Index Index of the type to return. @@ -144,9 +126,7 @@ struct type_list_element; */ template struct type_list_element> - : type_list_element> -{}; - + : type_list_element> {}; /** * @brief Provides compile-time indexed access to the types of a type list. @@ -159,7 +139,6 @@ struct type_list_element<0u, type_list> { using type = Type; }; - /** * @brief Helper type. * @tparam Index Index of the type to return. @@ -168,7 +147,6 @@ struct type_list_element<0u, type_list> { template using type_list_element_t = typename type_list_element::type; - /** * @brief Concatenates multiple type lists. * @tparam Type Types provided by the first type list. @@ -176,14 +154,14 @@ using type_list_element_t = typename type_list_element::type; * @return A type list composed by the types of both the type lists. */ template -constexpr type_list operator+(type_list, type_list) { return {}; } - +constexpr type_list operator+(type_list, type_list) { + return {}; +} /*! @brief Primary template isn't defined on purpose. */ template struct type_list_cat; - /*! @brief Concatenates multiple type lists. */ template<> struct type_list_cat<> { @@ -191,7 +169,6 @@ struct type_list_cat<> { using type = type_list<>; }; - /** * @brief Concatenates multiple type lists. * @tparam Type Types provided by the first type list. @@ -204,7 +181,6 @@ struct type_list_cat, type_list, List...> { using type = typename type_list_cat, List...>::type; }; - /** * @brief Concatenates multiple type lists. * @tparam Type Types provided by the type list. @@ -215,7 +191,6 @@ struct type_list_cat> { using type = type_list; }; - /** * @brief Helper type. * @tparam List Type lists to concatenate. @@ -223,12 +198,10 @@ struct type_list_cat> { template using type_list_cat_t = typename type_list_cat::type; - /*! @brief Primary template isn't defined on purpose. */ template struct type_list_unique; - /** * @brief Removes duplicates types from a type list. * @tparam Type One of the types provided by the given type list. @@ -240,11 +213,9 @@ struct type_list_unique> { using type = std::conditional_t< std::disjunction_v...>, typename type_list_unique>::type, - type_list_cat_t, typename type_list_unique>::type> - >; + type_list_cat_t, typename type_list_unique>::type>>; }; - /*! @brief Removes duplicates types from a type list. */ template<> struct type_list_unique> { @@ -252,7 +223,6 @@ struct type_list_unique> { using type = type_list<>; }; - /** * @brief Helper type. * @tparam Type A type list. @@ -260,7 +230,6 @@ struct type_list_unique> { template using type_list_unique_t = typename type_list_unique::type; - /** * @brief Provides the member constant `value` to true if a type list contains a * given type, false otherwise. @@ -270,7 +239,6 @@ using type_list_unique_t = typename type_list_unique::type; template struct type_list_contains; - /** * @copybrief type_list_contains * @tparam Type Types provided by the type list. @@ -279,7 +247,6 @@ struct type_list_contains; template struct type_list_contains, Other>: std::disjunction...> {}; - /** * @brief Helper variable template. * @tparam List Type list. @@ -288,12 +255,10 @@ struct type_list_contains, Other>: std::disjunction inline constexpr bool type_list_contains_v = type_list_contains::value; - /*! @brief Primary template isn't defined on purpose. */ template struct type_list_diff; - /** * @brief Computes the difference between two type lists. * @tparam Type Types provided by the first type list. @@ -305,7 +270,6 @@ struct type_list_diff, type_list> { using type = type_list_cat_t, Type>, type_list<>, type_list>...>; }; - /** * @brief Helper type. * @tparam List Type lists between which to compute the difference. @@ -313,7 +277,6 @@ struct type_list_diff, type_list> { template using type_list_diff_t = typename type_list_diff::type; - /** * @brief A class to use to push around lists of constant values, nothing more. * @tparam Value Values provided by the value list. @@ -326,12 +289,10 @@ struct value_list { static constexpr auto size = sizeof...(Value); }; - /*! @brief Primary template isn't defined on purpose. */ template struct value_list_element; - /** * @brief Provides compile-time indexed access to the values of a value list. * @tparam Index Index of the value to return. @@ -340,9 +301,7 @@ struct value_list_element; */ template struct value_list_element> - : value_list_element> -{}; - + : value_list_element> {}; /** * @brief Provides compile-time indexed access to the types of a type list. @@ -355,7 +314,6 @@ struct value_list_element<0u, value_list> { static constexpr auto value = Value; }; - /** * @brief Helper type. * @tparam Index Index of the value to return. @@ -364,7 +322,6 @@ struct value_list_element<0u, value_list> { template inline constexpr auto value_list_element_v = value_list_element::value; - /** * @brief Concatenates multiple value lists. * @tparam Value Values provided by the first value list. @@ -372,14 +329,14 @@ inline constexpr auto value_list_element_v = value_list_element::va * @return A value list composed by the values of both the value lists. */ template -constexpr value_list operator+(value_list, value_list) { return {}; } - +constexpr value_list operator+(value_list, value_list) { + return {}; +} /*! @brief Primary template isn't defined on purpose. */ template struct value_list_cat; - /*! @brief Concatenates multiple value lists. */ template<> struct value_list_cat<> { @@ -387,7 +344,6 @@ struct value_list_cat<> { using type = value_list<>; }; - /** * @brief Concatenates multiple value lists. * @tparam Value Values provided by the first value list. @@ -400,7 +356,6 @@ struct value_list_cat, value_list, List...> { using type = typename value_list_cat, List...>::type; }; - /** * @brief Concatenates multiple value lists. * @tparam Value Values provided by the value list. @@ -411,7 +366,6 @@ struct value_list_cat> { using type = value_list; }; - /** * @brief Helper type. * @tparam List Value lists to concatenate. @@ -419,12 +373,10 @@ struct value_list_cat> { template using value_list_cat_t = typename value_list_cat::type; - /*! @brief Same as std::is_invocable, but with tuples. */ template struct is_applicable: std::false_type {}; - /** * @copybrief is_applicable * @tparam Func A valid function type. @@ -434,7 +386,6 @@ struct is_applicable: std::false_type {}; template class Tuple, typename... Args> struct is_applicable>: std::is_invocable {}; - /** * @copybrief is_applicable * @tparam Func A valid function type. @@ -444,7 +395,6 @@ struct is_applicable>: std::is_invocable {}; template class Tuple, typename... Args> struct is_applicable>: std::is_invocable {}; - /** * @brief Helper variable template. * @tparam Func A valid function type. @@ -453,12 +403,10 @@ struct is_applicable>: std::is_invocable inline constexpr bool is_applicable_v = is_applicable::value; - /*! @brief Same as std::is_invocable_r, but with tuples for arguments. */ template struct is_applicable_r: std::false_type {}; - /** * @copybrief is_applicable_r * @tparam Ret The type to which the return type of the function should be @@ -469,7 +417,6 @@ struct is_applicable_r: std::false_type {}; template struct is_applicable_r>: std::is_invocable_r {}; - /** * @brief Helper variable template. * @tparam Ret The type to which the return type of the function should be @@ -480,7 +427,6 @@ struct is_applicable_r>: std::is_invocable_r inline constexpr bool is_applicable_r_v = is_applicable_r::value; - /** * @brief Provides the member constant `value` to true if a given type is * complete, false otherwise. @@ -489,12 +435,10 @@ inline constexpr bool is_applicable_r_v = is_applicable_r::valu template struct is_complete: std::false_type {}; - /*! @copydoc is_complete */ template struct is_complete>: std::true_type {}; - /** * @brief Helper variable template. * @tparam Type The type to test. @@ -502,7 +446,6 @@ struct is_complete>: std::true_type {} template inline constexpr bool is_complete_v = is_complete::value; - /** * @brief Provides the member constant `value` to true if a given type is an * iterator, false otherwise. @@ -511,13 +454,10 @@ inline constexpr bool is_complete_v = is_complete::value; template struct is_iterator: std::false_type {}; - /*! @copydoc is_iterator */ template struct is_iterator::iterator_category>> - : std::true_type -{}; - + : std::true_type {}; /** * @brief Helper variable template. @@ -526,7 +466,6 @@ struct is_iterator::iterat template inline constexpr bool is_iterator_v = is_iterator::value; - /** * @brief Provides the member constant `value` to true if a given type is of the * required iterator type, false otherwise. @@ -536,20 +475,15 @@ inline constexpr bool is_iterator_v = is_iterator::value; template struct is_iterator_type: std::false_type {}; - /*! @copydoc is_iterator_type */ template struct is_iterator_type && std::is_same_v>> - : std::true_type -{}; - + : std::true_type {}; /*! @copydoc is_iterator_type */ template struct is_iterator_type, std::void_t>> - : is_iterator_type -{}; - + : is_iterator_type {}; /** * @brief Helper variable template. @@ -559,7 +493,6 @@ struct is_iterator_type, st template inline constexpr bool is_iterator_type_v = is_iterator_type::value; - /** * @brief Provides the member constant `value` to true if a given type is both * an empty and non-final class, false otherwise. @@ -567,9 +500,7 @@ inline constexpr bool is_iterator_type_v = is_iterator_type::value; */ template struct is_ebco_eligible - : std::conjunction, std::negation>> -{}; - + : std::conjunction, std::negation>> {}; /** * @brief Helper variable template. @@ -578,23 +509,22 @@ struct is_ebco_eligible template inline constexpr bool is_ebco_eligible_v = is_ebco_eligible::value; - /** * @cond TURN_OFF_DOXYGEN * Internal details not to be documented. */ - namespace internal { - template -[[nodiscard]] constexpr bool is_equality_comparable(...) { return false; } - +[[nodiscard]] constexpr bool is_equality_comparable(...) { + return false; +} template -[[nodiscard]] constexpr auto is_equality_comparable(choice_t<0>) -> decltype(std::declval() == std::declval()) { return true; } - +[[nodiscard]] constexpr auto is_equality_comparable(choice_t<0>) -> decltype(std::declval() == std::declval()) { + return true; +} template [[nodiscard]] constexpr auto is_equality_comparable(choice_t<1>) -> decltype(std::declval(), std::declval() == std::declval()) { @@ -607,22 +537,18 @@ template } } - template [[nodiscard]] constexpr auto is_equality_comparable(choice_t<2>) -> decltype(std::declval(), std::declval() == std::declval()) { return is_equality_comparable(choice<2>) && is_equality_comparable(choice<2>); } - -} - +} // namespace internal /** * Internal details not to be documented. * @endcond */ - /** * @brief Provides the member constant `value` to true if a given type is * equality comparable, false otherwise. @@ -631,7 +557,6 @@ template template struct is_equality_comparable: std::bool_constant(choice<2>)> {}; - /** * @brief Helper variable template. * @tparam Type The type to test. @@ -639,7 +564,6 @@ struct is_equality_comparable: std::bool_constant inline constexpr bool is_equality_comparable_v = is_equality_comparable::value; - /** * @brief Transcribes the constness of a type to another type. * @tparam To The type to which to transcribe the constness. @@ -651,7 +575,6 @@ struct constness_as { using type = std::remove_const_t; }; - /*! @copydoc constness_as */ template struct constness_as { @@ -659,7 +582,6 @@ struct constness_as { using type = std::add_const_t; }; - /** * @brief Alias template to facilitate the transcription of the constness. * @tparam To The type to which to transcribe the constness. @@ -668,7 +590,6 @@ struct constness_as { template using constness_as_t = typename constness_as::type; - /** * @brief Extracts the class of a non-static member object or function. * @tparam Member A pointer to a non-static member object or function. @@ -678,20 +599,19 @@ class member_class { static_assert(std::is_member_pointer_v, "Invalid pointer type to non-static member object or function"); template - static Class * clazz(Ret(Class:: *)(Args...)); + static Class *clazz(Ret (Class::*)(Args...)); template - static Class * clazz(Ret(Class:: *)(Args...) const); + static Class *clazz(Ret (Class::*)(Args...) const); template - static Class * clazz(Type Class:: *); + static Class *clazz(Type Class::*); public: /*! @brief The class of the given non-static member object or function. */ using type = std::remove_pointer_t()))>; }; - /** * @brief Helper type. * @tparam Member A pointer to a non-static member object or function. @@ -699,8 +619,6 @@ public: template using member_class_t = typename member_class::type; - -} - +} // namespace entt #endif diff --git a/src/entt/core/utility.hpp b/src/entt/core/utility.hpp index 5a7ec16a9..30e798ca1 100644 --- a/src/entt/core/utility.hpp +++ b/src/entt/core/utility.hpp @@ -1,14 +1,11 @@ #ifndef ENTT_CORE_UTILITY_HPP #define ENTT_CORE_UTILITY_HPP - #include #include "../config/config.h" - namespace entt { - /*! @brief Identity function object (waiting for C++20). */ struct identity { /** @@ -18,12 +15,11 @@ struct identity { * @return The submitted value as-is. */ template - [[nodiscard]] constexpr Type && operator()(Type &&value) const ENTT_NOEXCEPT { + [[nodiscard]] constexpr Type &&operator()(Type &&value) const ENTT_NOEXCEPT { return std::forward(value); } }; - /** * @brief Constant utility to disambiguate overloaded members of a class. * @tparam Type Type of the desired overload. @@ -32,8 +28,9 @@ struct identity { * @return Pointer to the member. */ template -[[nodiscard]] constexpr auto overload(Type Class:: *member) ENTT_NOEXCEPT { return member; } - +[[nodiscard]] constexpr auto overload(Type Class::*member) ENTT_NOEXCEPT { + return member; +} /** * @brief Constant utility to disambiguate overloaded functions. @@ -42,8 +39,9 @@ template * @return Pointer to the function. */ template -[[nodiscard]] constexpr auto overload(Func *func) ENTT_NOEXCEPT { return func; } - +[[nodiscard]] constexpr auto overload(Func *func) ENTT_NOEXCEPT { + return func; +} /** * @brief Helper type for visitors. @@ -54,7 +52,6 @@ struct overloaded: Func... { using Func::operator()...; }; - /** * @brief Deduction guide. * @tparam Func Types of function objects. @@ -62,7 +59,6 @@ struct overloaded: Func... { template overloaded(Func...) -> overloaded; - /** * @brief Basic implementation of a y-combinator. * @tparam Func Type of a potentially recursive function. @@ -73,9 +69,8 @@ struct y_combinator { * @brief Constructs a y-combinator from a given function. * @param recursive A potentially recursive function. */ - y_combinator(Func recursive): - func{std::move(recursive)} - {} + y_combinator(Func recursive) + : func{std::move(recursive)} {} /** * @brief Invokes a y-combinator and therefore its underlying function. @@ -83,14 +78,14 @@ struct y_combinator { * @param args Parameters to use to invoke the underlying function. * @return Return value of the underlying function, if any. */ - template - decltype(auto) operator()(Args &&... args) const { + template + decltype(auto) operator()(Args &&...args) const { return func(*this, std::forward(args)...); } /*! @copydoc operator()() */ - template - decltype(auto) operator()(Args &&... args) { + template + decltype(auto) operator()(Args &&...args) { return func(*this, std::forward(args)...); } @@ -98,8 +93,6 @@ private: Func func; }; - -} - +} // namespace entt #endif diff --git a/src/entt/entity/component.hpp b/src/entt/entity/component.hpp index 37a72ceeb..d976b988e 100644 --- a/src/entt/entity/component.hpp +++ b/src/entt/entity/component.hpp @@ -1,14 +1,11 @@ #ifndef ENTT_ENTITY_COMPONENT_HPP #define ENTT_ENTITY_COMPONENT_HPP - #include #include "../config/config.h" - namespace entt { - /*! @brief Commonly used default traits for all types. */ struct basic_component_traits { /*! @brief Pointer stability, default is `std::false_type`. */ @@ -17,7 +14,6 @@ struct basic_component_traits { using ignore_if_empty = ENTT_IGNORE_IF_EMPTY; }; - /** * @brief Common way to access various properties of components. * @tparam Type Type of component. @@ -27,7 +23,6 @@ struct component_traits: basic_component_traits { static_assert(std::is_same_v, Type>, "Unsupported type"); }; - /** * @brief Helper variable template. * @tparam Type Type of component. @@ -35,16 +30,13 @@ struct component_traits: basic_component_traits { template inline constexpr bool in_place_delete_v = component_traits::in_place_delete::value; - /** * @brief Helper variable template. * @tparam Type Type of component. */ template -inline constexpr bool ignore_as_empty_v = component_traits::ignore_if_empty::value && std::is_empty_v; - - -} +inline constexpr bool ignore_as_empty_v = component_traits::ignore_if_empty::value &&std::is_empty_v; +} // namespace entt #endif diff --git a/src/entt/entity/entity.hpp b/src/entt/entity/entity.hpp index eb0ee0488..df6b7aa52 100644 --- a/src/entt/entity/entity.hpp +++ b/src/entt/entity/entity.hpp @@ -1,40 +1,30 @@ #ifndef ENTT_ENTITY_ENTITY_HPP #define ENTT_ENTITY_ENTITY_HPP - #include #include #include #include "../config/config.h" - namespace entt { - /** * @cond TURN_OFF_DOXYGEN * Internal details not to be documented. */ - namespace internal { - template struct entt_traits; - template struct entt_traits>> - : entt_traits> -{}; - + : entt_traits> {}; template struct entt_traits>> - : entt_traits -{}; - + : entt_traits {}; template<> struct entt_traits { @@ -46,7 +36,6 @@ struct entt_traits { static constexpr std::size_t entity_shift = 20u; }; - template<> struct entt_traits { using entity_type = std::uint64_t; @@ -57,16 +46,13 @@ struct entt_traits { static constexpr std::size_t entity_shift = 32u; }; - -} - +} // namespace internal /** * Internal details not to be documented. * @endcond */ - /** * @brief Entity traits. * @tparam Type Type of identifier. @@ -143,7 +129,6 @@ public: } }; - /** * @brief Converts an entity to its underlying type. * @tparam Entity The value type. @@ -155,7 +140,6 @@ template return entt_traits::to_integral(entity); } - /*! @brief Null object for all identifiers. */ struct null_t { /** @@ -211,7 +195,6 @@ struct null_t { } }; - /** * @brief Compares a null object and an identifier of any type. * @tparam Entity Type of identifier. @@ -224,7 +207,6 @@ template return other.operator==(entity); } - /** * @brief Compares a null object and an identifier of any type. * @tparam Entity Type of identifier. @@ -237,7 +219,6 @@ template return !(other == entity); } - /*! @brief Tombstone object for all identifiers. */ struct tombstone_t { /** @@ -293,7 +274,6 @@ struct tombstone_t { } }; - /** * @brief Compares a tombstone object and an identifier of any type. * @tparam Entity Type of identifier. @@ -306,7 +286,6 @@ template return other.operator==(entity); } - /** * @brief Compares a tombstone object and an identifier of any type. * @tparam Entity Type of identifier. @@ -319,7 +298,6 @@ template return !(other == entity); } - /** * @brief Compile-time constant for null entities. * @@ -329,7 +307,6 @@ template */ inline constexpr null_t null{}; - /** * @brief Compile-time constant for tombstone entities. * @@ -339,8 +316,6 @@ inline constexpr null_t null{}; */ inline constexpr tombstone_t tombstone{}; - -} - +} // namespace entt #endif diff --git a/src/entt/entity/fwd.hpp b/src/entt/entity/fwd.hpp index 1a3ee9af4..98f7ded6a 100644 --- a/src/entt/entity/fwd.hpp +++ b/src/entt/entity/fwd.hpp @@ -1,71 +1,54 @@ #ifndef ENTT_ENTITY_FWD_HPP #define ENTT_ENTITY_FWD_HPP - #include #include "../core/fwd.hpp" #include "utility.hpp" - namespace entt { - template> class basic_sparse_set; - template, typename = void> class basic_storage; - template class basic_registry; - template class basic_view; - template class basic_runtime_view; - template class basic_group; - template class basic_observer; - template class basic_organizer; - template struct basic_handle; - template class basic_snapshot; - template class basic_snapshot_loader; - template class basic_continuous_loader; - /*! @brief Default entity identifier. */ -enum class entity: id_type {}; - +enum class entity : id_type {}; /*! @brief Alias declaration for the most common use case. */ using sparse_set = basic_sparse_set; - /** * @brief Alias declaration for the most common use case. * @tparam Args Other template parameters. @@ -73,27 +56,21 @@ using sparse_set = basic_sparse_set; template using storage = basic_storage; - /*! @brief Alias declaration for the most common use case. */ using registry = basic_registry; - /*! @brief Alias declaration for the most common use case. */ using observer = basic_observer; - /*! @brief Alias declaration for the most common use case. */ using organizer = basic_organizer; - /*! @brief Alias declaration for the most common use case. */ using handle = basic_handle; - /*! @brief Alias declaration for the most common use case. */ using const_handle = basic_handle; - /** * @brief Alias declaration for the most common use case. * @tparam Args Other template parameters. @@ -101,7 +78,6 @@ using const_handle = basic_handle; template using handle_view = basic_handle; - /** * @brief Alias declaration for the most common use case. * @tparam Args Other template parameters. @@ -109,19 +85,15 @@ using handle_view = basic_handle; template using const_handle_view = basic_handle; - /*! @brief Alias declaration for the most common use case. */ using snapshot = basic_snapshot; - /*! @brief Alias declaration for the most common use case. */ using snapshot_loader = basic_snapshot_loader; - /*! @brief Alias declaration for the most common use case. */ using continuous_loader = basic_continuous_loader; - /** * @brief Alias declaration for the most common use case. * @tparam Get Types of components iterated by the view. @@ -130,11 +102,9 @@ using continuous_loader = basic_continuous_loader; template> using view = basic_view; - /*! @brief Alias declaration for the most common use case. */ using runtime_view = basic_runtime_view; - /** * @brief Alias declaration for the most common use case. * @tparam Args Other template parameters. @@ -142,8 +112,6 @@ using runtime_view = basic_runtime_view; template using group = basic_group; - -} - +} // namespace entt #endif diff --git a/src/entt/entity/group.hpp b/src/entt/entity/group.hpp index e61b66919..ff4d7fc2a 100644 --- a/src/entt/entity/group.hpp +++ b/src/entt/entity/group.hpp @@ -1,10 +1,9 @@ #ifndef ENTT_ENTITY_GROUP_HPP #define ENTT_ENTITY_GROUP_HPP - #include -#include #include +#include #include "../config/config.h" #include "../core/type_traits.hpp" #include "entity.hpp" @@ -13,10 +12,8 @@ #include "storage.hpp" #include "utility.hpp" - namespace entt { - /** * @brief Group. * @@ -26,7 +23,6 @@ namespace entt { template class basic_group; - /** * @brief Non-owning group. * @@ -85,10 +81,9 @@ class basic_group, get_t, exclude_t> final template iterable_iterator(It from, const std::tuple *...> &args) ENTT_NOEXCEPT : it{from}, - pools{args} - {} + pools{args} {} - iterable_iterator & operator++() ENTT_NOEXCEPT { + iterable_iterator &operator++() ENTT_NOEXCEPT { return ++it, *this; } @@ -119,10 +114,9 @@ class basic_group, get_t, exclude_t> final using iterator = iterable_iterator; using reverse_iterator = iterable_iterator; - iterable(basic_common_type * const ref, const std::tuple *...> &cpools) + iterable(basic_common_type *const ref, const std::tuple *...> &cpools) : handler{ref}, - pools{cpools} - {} + pools{cpools} {} [[nodiscard]] iterator begin() const ENTT_NOEXCEPT { return handler ? iterator{handler->begin(), pools} : iterator{{}, pools}; @@ -141,14 +135,13 @@ class basic_group, get_t, exclude_t> final } private: - basic_common_type * const handler; + basic_common_type *const handler; const std::tuple *...> pools; }; - basic_group(basic_common_type &ref, storage_type &... gpool) ENTT_NOEXCEPT + basic_group(basic_common_type &ref, storage_type &...gpool) ENTT_NOEXCEPT : handler{&ref}, - pools{&gpool...} - {} + pools{&gpool...} {} public: /*! @brief Underlying entity identifier. */ @@ -164,8 +157,7 @@ public: /*! @brief Default constructor to use to create empty, invalid groups. */ basic_group() ENTT_NOEXCEPT - : handler{} - {} + : handler{} {} /** * @brief Returns the number of entities that have the given components. @@ -436,7 +428,7 @@ public: * @param args Arguments to forward to the sort function object, if any. */ template - void sort(Compare compare, Sort algo = Sort{}, Args &&... args) { + void sort(Compare compare, Sort algo = Sort{}, Args &&...args) { if(*this) { if constexpr(sizeof...(Component) == 0) { static_assert(std::is_invocable_v, "Invalid comparison function"); @@ -479,11 +471,10 @@ public: } private: - basic_common_type * const handler; + basic_common_type *const handler; const std::tuple *...> pools; }; - /** * @brief Owning group. * @@ -556,10 +547,9 @@ class basic_group, get_t, exclude_t &other, const std::tuple *...> &cpools) ENTT_NOEXCEPT : it{from}, owned{std::get(other)...}, - get{cpools} - {} + get{cpools} {} - iterable_iterator & operator++() ENTT_NOEXCEPT { + iterable_iterator &operator++() ENTT_NOEXCEPT { return ++it, (++std::get(owned), ...), *this; } @@ -572,8 +562,7 @@ class basic_group, get_t, exclude_t(owned)...), - std::get *>(get)->get_as_tuple(*it)... - ); + std::get *>(get)->get_as_tuple(*it)...); } [[nodiscard]] bool operator==(const iterable_iterator &other) const ENTT_NOEXCEPT { @@ -593,17 +582,14 @@ class basic_group, get_t, exclude_t>, type_list<>, type_list>().end())>>...> - >; + type_list_cat_t>, type_list<>, type_list>().end())>>...>>; using reverse_iterator = iterable_iterator< typename basic_common_type::reverse_iterator, - type_list_cat_t>, type_list<>, type_list>().rbegin())>>...> - >; + type_list_cat_t>, type_list<>, type_list>().rbegin())>>...>>; - iterable(std::tuple *..., storage_type *...> cpools, const std::size_t * const extent) + iterable(std::tuple *..., storage_type *...> cpools, const std::size_t *const extent) : pools{cpools}, - length{extent} - {} + length{extent} {} [[nodiscard]] iterator begin() const ENTT_NOEXCEPT { auto it = length ? (std::get<0>(pools)->basic_common_type::end() - *length) : typename basic_common_type::iterator{}; @@ -627,13 +613,12 @@ class basic_group, get_t, exclude_t *..., storage_type *...> pools; - const std::size_t * const length; + const std::size_t *const length; }; - basic_group(const std::size_t &extent, storage_type &... opool, storage_type &... gpool) ENTT_NOEXCEPT + basic_group(const std::size_t &extent, storage_type &...opool, storage_type &...gpool) ENTT_NOEXCEPT : pools{&opool..., &gpool...}, - length{&extent} - {} + length{&extent} {} public: /*! @brief Underlying entity identifier. */ @@ -649,8 +634,7 @@ public: /*! @brief Default constructor to use to create empty, invalid groups. */ basic_group() ENTT_NOEXCEPT - : length{} - {} + : length{} {} /** * @brief Returns the number of entities that have the given components. @@ -862,7 +846,7 @@ public: if constexpr(is_applicable_v{}, std::declval().get({})))>) { std::apply(func, args); } else { - std::apply([&func](auto, auto &&... less) { func(std::forward(less)...); }, args); + std::apply([&func](auto, auto &&...less) { func(std::forward(less)...); }, args); } } } @@ -922,7 +906,7 @@ public: * @param args Arguments to forward to the sort function object, if any. */ template - void sort(Compare compare, Sort algo = Sort{}, Args &&... args) const { + void sort(Compare compare, Sort algo = Sort{}, Args &&...args) const { auto *cpool = std::get<0>(pools); if constexpr(sizeof...(Component) == 0) { @@ -940,7 +924,7 @@ public: cpool->sort_n(*length, std::move(comp), std::move(algo), std::forward(args)...); } - [this](auto *head, auto *... other) { + [this](auto *head, auto *...other) { for(auto next = *length; next; --next) { const auto pos = next - 1; [[maybe_unused]] const auto entt = head->data()[pos]; @@ -951,11 +935,9 @@ public: private: const std::tuple *..., storage_type *...> pools; - const size_type * const length; + const size_type *const length; }; - -} - +} // namespace entt #endif diff --git a/src/entt/entity/handle.hpp b/src/entt/entity/handle.hpp index d9a39a3b2..73ab459b0 100644 --- a/src/entt/entity/handle.hpp +++ b/src/entt/entity/handle.hpp @@ -1,7 +1,6 @@ #ifndef ENTT_ENTITY_HANDLE_HPP #define ENTT_ENTITY_HANDLE_HPP - #include #include #include @@ -10,10 +9,8 @@ #include "fwd.hpp" #include "registry.hpp" - namespace entt { - /** * @brief Non-owning handle to an entity. * @@ -35,8 +32,8 @@ struct basic_handle { /*! @brief Constructs an invalid handle. */ basic_handle() ENTT_NOEXCEPT - : reg{}, entt{null} - {} + : reg{}, + entt{null} {} /** * @brief Constructs a handle from a given registry and entity. @@ -44,8 +41,8 @@ struct basic_handle { * @param value A valid identifier. */ basic_handle(registry_type &ref, entity_type value) ENTT_NOEXCEPT - : reg{&ref}, entt{value} - {} + : reg{&ref}, + entt{value} {} /** * @brief Constructs a const handle from a non-const one. @@ -90,7 +87,7 @@ struct basic_handle { * @brief Returns a pointer to the underlying registry, if any. * @return A pointer to the underlying registry, if any. */ - [[nodiscard]] registry_type * registry() const ENTT_NOEXCEPT { + [[nodiscard]] registry_type *registry() const ENTT_NOEXCEPT { return reg; } @@ -128,7 +125,7 @@ struct basic_handle { * @return A reference to the newly created component. */ template - decltype(auto) emplace(Args &&... args) const { + decltype(auto) emplace(Args &&...args) const { static_assert(((sizeof...(Type) == 0) || ... || std::is_same_v), "Invalid type"); return reg->template emplace(entt, std::forward(args)...); } @@ -142,7 +139,7 @@ struct basic_handle { * @return A reference to the newly created component. */ template - decltype(auto) emplace_or_replace(Args &&... args) const { + decltype(auto) emplace_or_replace(Args &&...args) const { static_assert(((sizeof...(Type) == 0) || ... || std::is_same_v), "Invalid type"); return reg->template emplace_or_replace(entt, std::forward(args)...); } @@ -156,7 +153,7 @@ struct basic_handle { * @return A reference to the patched component. */ template - decltype(auto) patch(Func &&... func) const { + decltype(auto) patch(Func &&...func) const { static_assert(((sizeof...(Type) == 0) || ... || std::is_same_v), "Invalid type"); return reg->template patch(entt, std::forward(func)...); } @@ -170,7 +167,7 @@ struct basic_handle { * @return A reference to the component being replaced. */ template - decltype(auto) replace(Args &&... args) const { + decltype(auto) replace(Args &&...args) const { static_assert(((sizeof...(Type) == 0) || ... || std::is_same_v), "Invalid type"); return reg->template replace(entt, std::forward(args)...); } @@ -242,7 +239,7 @@ struct basic_handle { * @return Reference to the component owned by the handle. */ template - [[nodiscard]] decltype(auto) get_or_emplace(Args &&... args) const { + [[nodiscard]] decltype(auto) get_or_emplace(Args &&...args) const { static_assert(((sizeof...(Type) == 0) || ... || std::is_same_v), "Invalid type"); return reg->template get_or_emplace(entt, std::forward(args)...); } @@ -283,7 +280,6 @@ private: entity_type entt; }; - /** * @brief Compares two handles. * @tparam Args Scope of the first handle. @@ -298,7 +294,6 @@ template return lhs.registry() == rhs.registry() && lhs.entity() == rhs.entity(); } - /** * @brief Compares two handles. * @tparam Args Scope of the first handle. @@ -313,7 +308,6 @@ template return !(lhs == rhs); } - /** * @brief Deduction guide. * @tparam Entity A valid entity type (see entt_traits for more details). @@ -321,7 +315,6 @@ template template basic_handle(basic_registry &, Entity) -> basic_handle; - /** * @brief Deduction guide. * @tparam Entity A valid entity type (see entt_traits for more details). @@ -329,8 +322,6 @@ basic_handle(basic_registry &, Entity) -> basic_handle; template basic_handle(const basic_registry &, Entity) -> basic_handle; - -} - +} // namespace entt #endif diff --git a/src/entt/entity/helper.hpp b/src/entt/entity/helper.hpp index 7216f5521..286e36838 100644 --- a/src/entt/entity/helper.hpp +++ b/src/entt/entity/helper.hpp @@ -1,19 +1,16 @@ #ifndef ENTT_ENTITY_HELPER_HPP #define ENTT_ENTITY_HELPER_HPP - #include #include "../config/config.h" #include "../core/fwd.hpp" #include "../core/type_traits.hpp" #include "../signal/delegate.hpp" -#include "registry.hpp" #include "fwd.hpp" - +#include "registry.hpp" namespace entt { - /** * @brief Converts a registry to a view. * @tparam Entity A valid entity type (see entt_traits for more details). @@ -46,7 +43,6 @@ private: registry_type ® }; - /** * @brief Deduction guide. * @tparam Entity A valid entity type (see entt_traits for more details). @@ -54,7 +50,6 @@ private: template as_view(basic_registry &) -> as_view; - /** * @brief Deduction guide. * @tparam Entity A valid entity type (see entt_traits for more details). @@ -62,7 +57,6 @@ as_view(basic_registry &) -> as_view; template as_view(const basic_registry &) -> as_view; - /** * @brief Converts a registry to a group. * @tparam Entity A valid entity type (see entt_traits for more details). @@ -100,7 +94,6 @@ private: registry_type ® }; - /** * @brief Deduction guide. * @tparam Entity A valid entity type (see entt_traits for more details). @@ -108,7 +101,6 @@ private: template as_group(basic_registry &) -> as_group; - /** * @brief Deduction guide. * @tparam Entity A valid entity type (see entt_traits for more details). @@ -116,8 +108,6 @@ as_group(basic_registry &) -> as_group; template as_group(const basic_registry &) -> as_group; - - /** * @brief Helper to create a listener that directly invokes a member function. * @tparam Member Member function to invoke on a component of the given type. @@ -133,7 +123,6 @@ void invoke(basic_registry ®, const Entity entt) { func(reg, entt); } - /** * @brief Returns the entity associated with a given component. * @@ -161,8 +150,6 @@ Entity to_entity(const basic_registry ®, const Component &instance) { return null; } - -} - +} // namespace entt #endif diff --git a/src/entt/entity/observer.hpp b/src/entt/entity/observer.hpp index 733ce953e..ebcd5b4a6 100644 --- a/src/entt/entity/observer.hpp +++ b/src/entt/entity/observer.hpp @@ -1,30 +1,26 @@ #ifndef ENTT_ENTITY_OBSERVER_HPP #define ENTT_ENTITY_OBSERVER_HPP - -#include #include #include -#include +#include #include +#include #include "../config/config.h" #include "../core/type_traits.hpp" #include "../signal/delegate.hpp" +#include "entity.hpp" +#include "fwd.hpp" #include "registry.hpp" #include "storage.hpp" #include "utility.hpp" -#include "entity.hpp" -#include "fwd.hpp" - namespace entt { - /*! @brief Grouping matcher. */ template struct matcher {}; - /** * @brief Collector. * @@ -34,7 +30,6 @@ struct matcher {}; template struct basic_collector; - /** * @brief Collector. * @@ -114,11 +109,9 @@ struct basic_collector, type_list, Rule } }; - /*! @brief Variable template used to ease the definition of collectors. */ inline constexpr basic_collector<> collector{}; - /** * @brief Observer. * @@ -282,8 +275,7 @@ public: /*! @brief Default constructor. */ basic_observer() : release{}, - storage{} - {} + storage{} {} /*! @brief Default copy constructor, deleted on purpose. */ basic_observer(const basic_observer &) = delete; @@ -297,8 +289,7 @@ public: */ template basic_observer(basic_registry ®, basic_collector) - : basic_observer{} - { + : basic_observer{} { connect(reg, std::index_sequence_for{}); } @@ -309,13 +300,13 @@ public: * @brief Default copy assignment operator, deleted on purpose. * @return This observer. */ - basic_observer & operator=(const basic_observer &) = delete; + basic_observer &operator=(const basic_observer &) = delete; /** * @brief Default move assignment operator, deleted on purpose. * @return This observer. */ - basic_observer & operator=(basic_observer &&) = delete; + basic_observer &operator=(basic_observer &&) = delete; /** * @brief Connects an observer to a given registry. @@ -365,7 +356,7 @@ public: * * @return A pointer to the array of entities. */ - [[nodiscard]] const entity_type * data() const ENTT_NOEXCEPT { + [[nodiscard]] const entity_type *data() const ENTT_NOEXCEPT { return storage.data(); } @@ -440,8 +431,6 @@ private: basic_storage storage; }; - -} - +} // namespace entt #endif diff --git a/src/entt/entity/organizer.hpp b/src/entt/entity/organizer.hpp index 934ffbf87..3fd0e83ca 100644 --- a/src/entt/entity/organizer.hpp +++ b/src/entt/entity/organizer.hpp @@ -1,9 +1,8 @@ #ifndef ENTT_ENTITY_ORGANIZER_HPP #define ENTT_ENTITY_ORGANIZER_HPP - -#include #include +#include #include #include #include @@ -13,19 +12,15 @@ #include "fwd.hpp" #include "helper.hpp" - namespace entt { - /** * @cond TURN_OFF_DOXYGEN * Internal details not to be documented. */ - namespace internal { - template struct is_view: std::false_type {}; @@ -35,20 +30,17 @@ struct is_view, exclude_t>>: template inline constexpr bool is_view_v = is_view::value; - template struct unpack_type { using ro = std::conditional_t< type_list_contains_v> || (std::is_const_v && !type_list_contains_v>), type_list>, - type_list<> - >; + type_list<>>; using rw = std::conditional_t< type_list_contains_v> || (!std::is_const_v && !type_list_contains_v>), type_list, - type_list<> - >; + type_list<>>; }; template @@ -59,8 +51,7 @@ struct unpack_type, type_list> { template struct unpack_type, type_list> - : unpack_type, type_list> -{}; + : unpack_type, type_list> {}; template struct unpack_type, exclude_t>, type_list> { @@ -70,9 +61,7 @@ struct unpack_type, exclude_t template struct unpack_type, exclude_t>, type_list> - : unpack_type, exclude_t>, type_list> -{}; - + : unpack_type, exclude_t>, type_list> {}; template struct resource; @@ -84,32 +73,28 @@ struct resource, type_list> { using rw = type_list_cat_t>::rw..., typename unpack_type>::rw...>; }; - template -resource...>, type_list> free_function_to_resource(Ret(*)(Args...)); +resource...>, type_list> free_function_to_resource(Ret (*)(Args...)); template -resource...>, type_list> constrained_function_to_resource(Ret(*)(Type &, Args...)); +resource...>, type_list> constrained_function_to_resource(Ret (*)(Type &, Args...)); template -resource...>, type_list> constrained_function_to_resource(Ret(Class:: *)(Args...)); +resource...>, type_list> constrained_function_to_resource(Ret (Class::*)(Args...)); template -resource...>, type_list> constrained_function_to_resource(Ret(Class:: *)(Args...) const); +resource...>, type_list> constrained_function_to_resource(Ret (Class::*)(Args...) const); template resource, type_list> to_resource(); - -} - +} // namespace internal /** * Internal details not to be documented. * @endcond */ - /** * @brief Utility class for creating a static task graph. * @@ -262,8 +247,7 @@ public: vertex(const bool vtype, vertex_data data, std::vector edges) : is_top_level{vtype}, node{std::move(data)}, - reachable{std::move(edges)} - {} + reachable{std::move(edges)} {} /** * @brief Fills a buffer with the type info objects for the writable @@ -323,7 +307,7 @@ public: * @brief Returns a user defined name associated with a vertex, if any. * @return The user defined name associated with the vertex, if any. */ - const char * name() const ENTT_NOEXCEPT { + const char *name() const ENTT_NOEXCEPT { return node.name; } @@ -331,7 +315,7 @@ public: * @brief Returns the function associated with a vertex. * @return The function associated with the vertex. */ - function_type * callback() const ENTT_NOEXCEPT { + function_type *callback() const ENTT_NOEXCEPT { return node.callback; } @@ -339,7 +323,7 @@ public: * @brief Returns the payload associated with a vertex, if any. * @return The payload associated with the vertex, if any. */ - const void * data() const ENTT_NOEXCEPT { + const void *data() const ENTT_NOEXCEPT { return node.payload; } @@ -347,7 +331,7 @@ public: * @brief Returns the list of nodes reachable from a given vertex. * @return The list of nodes reachable from the vertex. */ - const std::vector & children() const ENTT_NOEXCEPT { + const std::vector &children() const ENTT_NOEXCEPT { return reachable; } @@ -381,7 +365,7 @@ public: std::apply(Candidate, to_args(reg, typename resource_type::args{})); }; - vertex_data vdata { + vertex_data vdata{ resource_type::ro::size, resource_type::rw::size, name, @@ -389,8 +373,7 @@ public: callback, +[](const bool rw, type_info *buffer, const std::size_t length) { return rw ? fill_dependencies(typename resource_type::rw{}, buffer, length) : fill_dependencies(typename resource_type::ro{}, buffer, length); }, +[](basic_registry ®) { void(to_args(reg, typename resource_type::args{})); }, - type_id>() - }; + type_id>()}; track_dependencies(vertices.size(), requires_registry, typename resource_type::ro{}, typename resource_type::rw{}); vertices.push_back(std::move(vdata)); @@ -415,7 +398,7 @@ public: std::apply(Candidate, std::tuple_cat(std::forward_as_tuple(*curr), to_args(reg, typename resource_type::args{}))); }; - vertex_data vdata { + vertex_data vdata{ resource_type::ro::size, resource_type::rw::size, name, @@ -423,8 +406,7 @@ public: callback, +[](const bool rw, type_info *buffer, const std::size_t length) { return rw ? fill_dependencies(typename resource_type::rw{}, buffer, length) : fill_dependencies(typename resource_type::ro{}, buffer, length); }, +[](basic_registry ®) { void(to_args(reg, typename resource_type::args{})); }, - type_id>() - }; + type_id>()}; track_dependencies(vertices.size(), requires_registry, typename resource_type::ro{}, typename resource_type::rw{}); vertices.push_back(std::move(vdata)); @@ -443,7 +425,7 @@ public: using resource_type = internal::resource, type_list>; track_dependencies(vertices.size(), true, typename resource_type::ro{}, typename resource_type::rw{}); - vertex_data vdata { + vertex_data vdata{ resource_type::ro::size, resource_type::rw::size, name, @@ -451,8 +433,7 @@ public: func, +[](const bool rw, type_info *buffer, const std::size_t length) { return rw ? fill_dependencies(typename resource_type::rw{}, buffer, length) : fill_dependencies(typename resource_type::ro{}, buffer, length); }, nullptr, - type_info{} - }; + type_info{}}; vertices.push_back(std::move(vdata)); } @@ -500,8 +481,6 @@ private: std::vector vertices; }; - -} - +} // namespace entt #endif diff --git a/src/entt/entity/poly_storage.hpp b/src/entt/entity/poly_storage.hpp index a3f04fe68..436858007 100644 --- a/src/entt/entity/poly_storage.hpp +++ b/src/entt/entity/poly_storage.hpp @@ -1,7 +1,6 @@ #ifndef ENTT_ENTITY_POLY_STORAGE_HPP #define ENTT_ENTITY_POLY_STORAGE_HPP - #include #include #include "../core/type_info.hpp" @@ -9,10 +8,8 @@ #include "../poly/poly.hpp" #include "fwd.hpp" - namespace entt { - /** * @brief Basic poly storage implementation. * @tparam Entity A valid entity type (see entt_traits for more details). @@ -42,7 +39,6 @@ struct Storage: type_list { using impl = value_list<&type_id>; }; - /** * @brief Defines the poly storage type associate with a given entity type. * @tparam Entity A valid entity type (see entt_traits for more details). @@ -53,8 +49,6 @@ struct poly_storage_traits { using storage_type = poly>; }; - -} - +} // namespace entt #endif diff --git a/src/entt/entity/registry.hpp b/src/entt/entity/registry.hpp index a5d400698..adfb29096 100644 --- a/src/entt/entity/registry.hpp +++ b/src/entt/entity/registry.hpp @@ -1,7 +1,6 @@ #ifndef ENTT_ENTITY_REGISTRY_HPP #define ENTT_ENTITY_REGISTRY_HPP - #include #include #include @@ -27,10 +26,8 @@ #include "utility.hpp" #include "view.hpp" - namespace entt { - /** * @brief Fast and reliable entity-component system. * @@ -69,8 +66,8 @@ class basic_registry { [[maybe_unused]] const auto cpools = std::make_tuple(owner.assure()...); const auto is_valid = ((std::is_same_v || std::get *>(cpools)->contains(entt)) && ...) - && ((std::is_same_v || owner.assure()->contains(entt)) && ...) - && ((std::is_same_v || !owner.assure()->contains(entt)) && ...); + && ((std::is_same_v || owner.assure()->contains(entt)) && ...) + && ((std::is_same_v || !owner.assure()->contains(entt)) && ...); if constexpr(sizeof...(Owned) == 0) { if(is_valid && !current.contains(entt)) { @@ -98,19 +95,19 @@ class basic_registry { struct group_data { std::size_t size; - std::unique_ptr group; - bool (* owned)(const id_type) ENTT_NOEXCEPT; - bool (* get)(const id_type) ENTT_NOEXCEPT; - bool (* exclude)(const id_type) ENTT_NOEXCEPT; + std::unique_ptr group; + bool (*owned)(const id_type) ENTT_NOEXCEPT; + bool (*get)(const id_type) ENTT_NOEXCEPT; + bool (*exclude)(const id_type) ENTT_NOEXCEPT; }; template - [[nodiscard]] storage_type * assure() const { + [[nodiscard]] storage_type *assure() const { static_assert(std::is_same_v>, "Non-decayed types not allowed"); const auto index = type_index::value(); if(!(index < pools.size())) { - pools.resize(size_type(index)+1u); + pools.resize(size_type(index) + 1u); } if(auto &&pdata = pools[index]; !pdata.pool) { @@ -122,7 +119,7 @@ class basic_registry { } template - [[nodiscard]] const storage_type * pool_if_exists() const ENTT_NOEXCEPT { + [[nodiscard]] const storage_type *pool_if_exists() const ENTT_NOEXCEPT { static_assert(std::is_same_v>, "Non-decayed types not allowed"); const auto index = type_index::value(); return (!(index < pools.size()) || !pools[index].pool) ? nullptr : static_cast *>(pools[index].pool.get()); @@ -164,7 +161,7 @@ public: basic_registry(basic_registry &&) = default; /*! @brief Default move assignment operator. @return This registry. */ - basic_registry & operator=(basic_registry &&) = default; + basic_registry &operator=(basic_registry &&) = default; /** * @brief Prepares a pool for the given type if required. @@ -182,13 +179,13 @@ public: * @return A valid poly storage if a pool for the given type exists, an * empty and thus invalid element otherwise. */ - poly_storage & storage(const type_info info) { + poly_storage &storage(const type_info info) { ENTT_ASSERT(info.index() < pools.size() && pools[info.index()].poly, "Storage not available"); return pools[info.index()].poly; } /*! @copydoc storage */ - const poly_storage & storage(const type_info info) const { + const poly_storage &storage(const type_info info) const { ENTT_ASSERT(info.index() < pools.size() && pools[info.index()].poly, "Storage not available"); return pools[info.index()].poly; } @@ -294,7 +291,7 @@ public: if constexpr(sizeof...(Component) == 0) { return !alive(); } else { - return [](const auto *... cpool) { return ((!cpool || cpool->empty()) && ...); }(pool_if_exists()...); + return [](const auto *...cpool) { return ((!cpool || cpool->empty()) && ...); }(pool_if_exists()...); } } @@ -310,7 +307,7 @@ public: * * @return A pointer to the array of entities. */ - [[nodiscard]] const entity_type * data() const ENTT_NOEXCEPT { + [[nodiscard]] const entity_type *data() const ENTT_NOEXCEPT { return entities.data(); } @@ -525,7 +522,7 @@ public: ENTT_ASSERT(valid(entity), "Invalid entity"); for(auto &&pdata: pools) { - pdata.pool && pdata.pool->remove(entity, this); + pdata.pool &&pdata.pool->remove(entity, this); } return release_entity(entity, version); @@ -548,7 +545,7 @@ public: } } else { for(auto &&pdata: pools) { - pdata.pool && pdata.pool->remove(first, last, this); + pdata.pool &&pdata.pool->remove(first, last, this); } release(first, last); @@ -573,7 +570,7 @@ public: * @return A reference to the newly created component. */ template - decltype(auto) emplace(const entity_type entity, Args &&... args) { + decltype(auto) emplace(const entity_type entity, Args &&...args) { ENTT_ASSERT(valid(entity), "Invalid entity"); return assure()->emplace(*this, entity, std::forward(args)...); } @@ -635,13 +632,13 @@ public: * @return A reference to the newly created component. */ template - decltype(auto) emplace_or_replace(const entity_type entity, Args &&... args) { + decltype(auto) emplace_or_replace(const entity_type entity, Args &&...args) { ENTT_ASSERT(valid(entity), "Invalid entity"); auto *cpool = assure(); return cpool->contains(entity) - ? cpool->patch(*this, entity, [&args...](auto &... curr) { ((curr = Component{std::forward(args)...}), ...); }) - : cpool->emplace(*this, entity, std::forward(args)...); + ? cpool->patch(*this, entity, [&args...](auto &...curr) { ((curr = Component{std::forward(args)...}), ...); }) + : cpool->emplace(*this, entity, std::forward(args)...); } /** @@ -669,7 +666,7 @@ public: * @return A reference to the patched component. */ template - decltype(auto) patch(const entity_type entity, Func &&... func) { + decltype(auto) patch(const entity_type entity, Func &&...func) { ENTT_ASSERT(valid(entity), "Invalid entity"); return assure()->patch(*this, entity, std::forward(func)...); } @@ -692,8 +689,8 @@ public: * @return A reference to the component being replaced. */ template - decltype(auto) replace(const entity_type entity, Args &&... args) { - return assure()->patch(*this, entity, [&args...](auto &... curr) { ((curr = Component{std::forward(args)...}), ...); }); + decltype(auto) replace(const entity_type entity, Args &&...args) { + return assure()->patch(*this, entity, [&args...](auto &...curr) { ((curr = Component{std::forward(args)...}), ...); }); } /** @@ -807,7 +804,7 @@ public: template [[nodiscard]] bool all_of(const entity_type entity) const { ENTT_ASSERT(valid(entity), "Invalid entity"); - return [entity](const auto *... cpool) { return ((cpool && cpool->contains(entity)) && ...); }(pool_if_exists()...); + return [entity](const auto *...cpool) { return ((cpool && cpool->contains(entity)) && ...); }(pool_if_exists()...); } /** @@ -824,7 +821,7 @@ public: template [[nodiscard]] bool any_of(const entity_type entity) const { ENTT_ASSERT(valid(entity), "Invalid entity"); - return [entity](const auto *... cpool) { return !((!cpool || !cpool->contains(entity)) && ...); }(pool_if_exists()...); + return [entity](const auto *...cpool) { return !((!cpool || !cpool->contains(entity)) && ...); }(pool_if_exists()...); } /** @@ -886,7 +883,7 @@ public: * @return Reference to the component owned by the entity. */ template - [[nodiscard]] decltype(auto) get_or_emplace(const entity_type entity, Args &&... args) { + [[nodiscard]] decltype(auto) get_or_emplace(const entity_type entity, Args &&...args) { ENTT_ASSERT(valid(entity), "Invalid entity"); auto *cpool = assure(); return cpool->contains(entity) ? cpool->get(entity) : cpool->emplace(*this, entity, std::forward(args)...); @@ -967,7 +964,7 @@ public: void each(Func func) const { if(free_list == null) { for(auto pos = entities.size(); pos; --pos) { - func(entities[pos-1]); + func(entities[pos - 1]); } } else { for(auto pos = entities.size(); pos; --pos) { @@ -1121,14 +1118,14 @@ public: template [[nodiscard]] basic_view...>, exclude_t> view(exclude_t = {}) const { static_assert(sizeof...(Component) > 0, "Exclusion-only views are not supported"); - return { *assure>()..., *assure()... }; + return {*assure>()..., *assure()...}; } /*! @copydoc view */ template [[nodiscard]] basic_view, exclude_t> view(exclude_t = {}) { static_assert(sizeof...(Component) > 0, "Exclusion-only views are not supported"); - return { *assure>()..., *assure()... }; + return {*assure>()..., *assure()...}; } /** @@ -1174,7 +1171,7 @@ public: return it == pools.cend() ? nullptr : it->pool.get(); }); - return { std::move(component), std::move(filter) }; + return {std::move(component), std::move(filter)}; } /** @@ -1227,7 +1224,7 @@ public: } else { group_data candidate = { size, - { new handler_type{}, [](void *instance) { delete static_cast(instance); } }, + {new handler_type{}, [](void *instance) { delete static_cast(instance); }}, []([[maybe_unused]] const id_type ctype) ENTT_NOEXCEPT { return ((ctype == type_hash>::value()) || ...); }, []([[maybe_unused]] const id_type ctype) ENTT_NOEXCEPT { return ((ctype == type_hash>::value()) || ...); }, []([[maybe_unused]] const id_type ctype) ENTT_NOEXCEPT { return ((ctype == type_hash::value()) || ...); }, @@ -1282,7 +1279,7 @@ public: } } - return { handler->current, *std::get> *>(cpools)..., *std::get> *>(cpools)... }; + return {handler->current, *std::get> *>(cpools)..., *std::get> *>(cpools)...}; } /** @@ -1308,7 +1305,7 @@ public: return {}; } else { using handler_type = group_handler, get_t...>, std::remove_const_t...>; - return { static_cast(it->group.get())->current, *pool_if_exists>()... , *pool_if_exists>()... }; + return {static_cast(it->group.get())->current, *pool_if_exists>()..., *pool_if_exists>()...}; } } @@ -1411,7 +1408,7 @@ public: * @param args Arguments to forward to the sort function object, if any. */ template - void sort(Compare compare, Sort algo = Sort{}, Args &&... args) { + void sort(Compare compare, Sort algo = Sort{}, Args &&...args) { ENTT_ASSERT(sortable(), "Cannot sort owned storage"); auto *cpool = assure(); @@ -1490,7 +1487,7 @@ public: template void visit(entity_type entity, Func func) const { for(auto pos = pools.size(); pos; --pos) { - if(const auto &pdata = pools[pos-1]; pdata.pool && pdata.pool->contains(entity)) { + if(const auto &pdata = pools[pos - 1]; pdata.pool && pdata.pool->contains(entity)) { func(pdata.poly->value_type()); } } @@ -1519,7 +1516,7 @@ public: template void visit(Func func) const { for(auto pos = pools.size(); pos; --pos) { - if(const auto &pdata = pools[pos-1]; pdata.pool) { + if(const auto &pdata = pools[pos - 1]; pdata.pool) { func(pdata.poly->value_type()); } } @@ -1537,7 +1534,7 @@ public: * @return A reference to the newly created object. */ template - Type & set(Args &&... args) { + Type &set(Args &&...args) { unset(); vars.emplace_back(std::in_place_type, std::forward(args)...); return any_cast(vars.back()); @@ -1564,7 +1561,7 @@ public: * @return A reference to the object in the context of the registry. */ template - [[nodiscard]] Type & ctx_or_set(Args &&... args) { + [[nodiscard]] Type &ctx_or_set(Args &&...args) { auto *value = try_ctx(); return value ? *value : set(std::forward(args)...); } @@ -1576,14 +1573,14 @@ public: * registry, a null pointer otherwise. */ template - [[nodiscard]] std::add_const_t * try_ctx() const { + [[nodiscard]] std::add_const_t *try_ctx() const { auto it = std::find_if(vars.cbegin(), vars.cend(), [type = type_id()](auto &&var) { return var.type() == type; }); return it == vars.cend() ? nullptr : any_cast>(&*it); } /*! @copydoc try_ctx */ template - [[nodiscard]] Type * try_ctx() { + [[nodiscard]] Type *try_ctx() { auto it = std::find_if(vars.begin(), vars.end(), [type = type_id()](auto &&var) { return var.type() == type; }); return it == vars.end() ? nullptr : any_cast(&*it); } @@ -1599,7 +1596,7 @@ public: * @return A valid reference to the object in the context of the registry. */ template - [[nodiscard]] std::add_const_t & ctx() const { + [[nodiscard]] std::add_const_t &ctx() const { auto it = std::find_if(vars.cbegin(), vars.cend(), [type = type_id()](auto &&var) { return var.type() == type; }); ENTT_ASSERT(it != vars.cend(), "Invalid instance"); return any_cast &>(*it); @@ -1607,7 +1604,7 @@ public: /*! @copydoc ctx */ template - [[nodiscard]] Type & ctx() { + [[nodiscard]] Type &ctx() { auto it = std::find_if(vars.begin(), vars.end(), [type = type_id()](auto &&var) { return var.type() == type; }); ENTT_ASSERT(it != vars.end(), "Invalid instance"); return any_cast(*it); @@ -1637,7 +1634,7 @@ public: template void ctx(Func func) const { for(auto pos = vars.size(); pos; --pos) { - func(vars[pos-1].type()); + func(vars[pos - 1].type()); } } @@ -1649,8 +1646,6 @@ private: entity_type free_list{tombstone}; }; - -} - +} // namespace entt #endif diff --git a/src/entt/entity/runtime_view.hpp b/src/entt/entity/runtime_view.hpp index 886a982b5..d874d6fdc 100644 --- a/src/entt/entity/runtime_view.hpp +++ b/src/entt/entity/runtime_view.hpp @@ -1,21 +1,18 @@ #ifndef ENTT_ENTITY_RUNTIME_VIEW_HPP #define ENTT_ENTITY_RUNTIME_VIEW_HPP - -#include -#include -#include #include +#include #include +#include +#include #include "../config/config.h" #include "entity.hpp" -#include "sparse_set.hpp" #include "fwd.hpp" - +#include "sparse_set.hpp" namespace entt { - /** * @brief Runtime view. * @@ -62,8 +59,8 @@ class basic_runtime_view final { class view_iterator final { [[nodiscard]] bool valid() const { return (no_tombstone_check || (*it != tombstone)) - && std::all_of(pools->begin()++, pools->end(), [entt = *it](const auto *curr) { return curr->contains(entt); }) - && std::none_of(filter->cbegin(), filter->cend(), [entt = *it](const auto *curr) { return curr && curr->contains(entt); }); + && std::all_of(pools->begin()++, pools->end(), [entt = *it](const auto *curr) { return curr->contains(entt); }) + && std::none_of(filter->cbegin(), filter->cend(), [entt = *it](const auto *curr) { return curr && curr->contains(entt); }); } public: @@ -79,14 +76,13 @@ class basic_runtime_view final { : pools{&cpools}, filter{&ignore}, it{curr}, - no_tombstone_check{std::all_of(pools->cbegin(), pools->cend(), [](const basic_common_type *cpool) { return (cpool->policy() == deletion_policy::swap_and_pop); })} - { + no_tombstone_check{std::all_of(pools->cbegin(), pools->cend(), [](const basic_common_type *cpool) { return (cpool->policy() == deletion_policy::swap_and_pop); })} { if(it != (*pools)[0]->end() && !valid()) { ++(*this); } } - view_iterator & operator++() { + view_iterator &operator++() { while(++it != (*pools)[0]->end() && !valid()) { continue; } return *this; } @@ -96,7 +92,7 @@ class basic_runtime_view final { return ++(*this), orig; } - view_iterator & operator--() ENTT_NOEXCEPT { + view_iterator &operator--() ENTT_NOEXCEPT { while(--it != (*pools)[0]->begin() && !valid()) { continue; } return *this; } @@ -144,8 +140,7 @@ public: /*! @brief Default constructor to use to create empty, invalid views. */ basic_runtime_view() ENTT_NOEXCEPT : pools{}, - filter{} - {} + filter{} {} /** * @brief Constructs a runtime view from a set of storage classes. @@ -154,8 +149,7 @@ public: */ basic_runtime_view(std::vector cpools, std::vector epools) ENTT_NOEXCEPT : pools{std::move(cpools)}, - filter{std::move(epools)} - { + filter{std::move(epools)} { auto candidate = std::min_element(pools.begin(), pools.end(), [](const auto *lhs, const auto *rhs) { return (!lhs && rhs) || (lhs && rhs && lhs->size() < rhs->size()); }); @@ -208,7 +202,7 @@ public: */ [[nodiscard]] bool contains(const entity_type entt) const { return valid() && std::all_of(pools.cbegin(), pools.cend(), [entt](const auto *curr) { return curr->contains(entt); }) - && std::none_of(filter.cbegin(), filter.cend(), [entt](const auto *curr) { return curr && curr->contains(entt); }); + && std::none_of(filter.cbegin(), filter.cend(), [entt](const auto *curr) { return curr && curr->contains(entt); }); } /** @@ -238,8 +232,6 @@ private: std::vector filter; }; - -} - +} // namespace entt #endif diff --git a/src/entt/entity/snapshot.hpp b/src/entt/entity/snapshot.hpp index 77cb44b6f..85b5beb25 100644 --- a/src/entt/entity/snapshot.hpp +++ b/src/entt/entity/snapshot.hpp @@ -1,7 +1,6 @@ #ifndef ENTT_ENTITY_SNAPSHOT_HPP #define ENTT_ENTITY_SNAPSHOT_HPP - #include #include #include @@ -16,10 +15,8 @@ #include "fwd.hpp" #include "registry.hpp" - namespace entt { - /** * @brief Utility class to create snapshots from a registry. * @@ -70,14 +67,13 @@ public: * @param source A valid reference to a registry. */ basic_snapshot(const basic_registry &source) ENTT_NOEXCEPT - : reg{&source} - {} + : reg{&source} {} /*! @brief Default move constructor. */ basic_snapshot(basic_snapshot &&) = default; /*! @brief Default move assignment operator. @return This snapshot. */ - basic_snapshot & operator=(basic_snapshot &&) = default; + basic_snapshot &operator=(basic_snapshot &&) = default; /** * @brief Puts aside all the entities from the underlying registry. @@ -90,7 +86,7 @@ public: * @return An object of this type to continue creating the snapshot. */ template - const basic_snapshot & entities(Archive &archive) const { + const basic_snapshot &entities(Archive &archive) const { const auto sz = reg->size(); archive(typename entity_traits::entity_type(sz + 1u)); @@ -115,7 +111,7 @@ public: * @return An object of this type to continue creating the snapshot. */ template - const basic_snapshot & component(Archive &archive) const { + const basic_snapshot &component(Archive &archive) const { if constexpr(sizeof...(Component) == 1u) { const auto view = reg->template view(); (component(archive, view.data(), view.data() + view.size()), ...); @@ -141,7 +137,7 @@ public: * @return An object of this type to continue creating the snapshot. */ template - const basic_snapshot & component(Archive &archive, It first, It last) const { + const basic_snapshot &component(Archive &archive, It first, It last) const { component(archive, first, last, std::index_sequence_for{}); return *this; } @@ -150,7 +146,6 @@ private: const basic_registry *reg; }; - /** * @brief Utility class to restore a snapshot as a whole. * @@ -200,8 +195,7 @@ public: * @param source A valid reference to a registry. */ basic_snapshot_loader(basic_registry &source) ENTT_NOEXCEPT - : reg{&source} - { + : reg{&source} { // restoring a snapshot as a whole requires a clean registry ENTT_ASSERT(reg->empty(), "Registry must be empty"); } @@ -210,7 +204,7 @@ public: basic_snapshot_loader(basic_snapshot_loader &&) = default; /*! @brief Default move assignment operator. @return This loader. */ - basic_snapshot_loader & operator=(basic_snapshot_loader &&) = default; + basic_snapshot_loader &operator=(basic_snapshot_loader &&) = default; /** * @brief Restores entities that were in use during serialization. @@ -223,7 +217,7 @@ public: * @return A valid loader to continue restoring data. */ template - const basic_snapshot_loader & entities(Archive &archive) const { + const basic_snapshot_loader &entities(Archive &archive) const { typename entity_traits::entity_type length{}; archive(length); @@ -252,7 +246,7 @@ public: * @return A valid loader to continue restoring data. */ template - const basic_snapshot_loader & component(Archive &archive) const { + const basic_snapshot_loader &component(Archive &archive) const { (assign(archive), ...); return *this; } @@ -267,7 +261,7 @@ public: * * @return A valid loader to continue restoring data. */ - const basic_snapshot_loader & orphans() const { + const basic_snapshot_loader &orphans() const { reg->orphans([this](const auto entt) { reg->release(entt); }); @@ -279,7 +273,6 @@ private: basic_registry *reg; }; - /** * @brief Utility class for _continuous loading_. * @@ -326,7 +319,7 @@ class basic_continuous_loader { template auto update(int, Container &container) - -> decltype(typename Container::mapped_type{}, void()) { + -> decltype(typename Container::mapped_type{}, void()) { // map like container Container other; @@ -349,7 +342,7 @@ class basic_continuous_loader { template auto update(char, Container &container) - -> decltype(typename Container::value_type{}, void()) { + -> decltype(typename Container::value_type{}, void()) { // vector like container static_assert(std::is_same_v, "Invalid value type"); @@ -359,7 +352,7 @@ class basic_continuous_loader { } template - void update([[maybe_unused]] Other &instance, [[maybe_unused]] Member Type:: *member) { + void update([[maybe_unused]] Other &instance, [[maybe_unused]] Member Type::*member) { if constexpr(!std::is_same_v) { return; } else if constexpr(std::is_same_v) { @@ -382,7 +375,7 @@ class basic_continuous_loader { } template - void assign(Archive &archive, [[maybe_unused]] Member Type:: *... member) { + void assign(Archive &archive, [[maybe_unused]] Member Type::*...member) { typename entity_traits::entity_type length{}; archive(length); @@ -415,14 +408,13 @@ public: * @param source A valid reference to a registry. */ basic_continuous_loader(basic_registry &source) ENTT_NOEXCEPT - : reg{&source} - {} + : reg{&source} {} /*! @brief Default move constructor. */ basic_continuous_loader(basic_continuous_loader &&) = default; /*! @brief Default move assignment operator. @return This loader. */ - basic_continuous_loader & operator=(basic_continuous_loader &&) = default; + basic_continuous_loader &operator=(basic_continuous_loader &&) = default; /** * @brief Restores entities that were in use during serialization. @@ -435,7 +427,7 @@ public: * @return A non-const reference to this loader. */ template - basic_continuous_loader & entities(Archive &archive) { + basic_continuous_loader &entities(Archive &archive) { typename entity_traits::entity_type length{}; entity_type entt{}; @@ -476,7 +468,7 @@ public: * @return A non-const reference to this loader. */ template - basic_continuous_loader & component(Archive &archive, Member Type:: *... member) { + basic_continuous_loader &component(Archive &archive, Member Type::*...member) { (remove_if_exists(), ...); (assign(archive, member...), ...); return *this; @@ -490,7 +482,7 @@ public: * * @return A non-const reference to this loader. */ - basic_continuous_loader & shrink() { + basic_continuous_loader &shrink() { auto it = remloc.begin(); while(it != remloc.cend()) { @@ -522,7 +514,7 @@ public: * * @return A non-const reference to this loader. */ - basic_continuous_loader & orphans() { + basic_continuous_loader &orphans() { reg->orphans([this](const auto entt) { reg->release(entt); }); @@ -560,8 +552,6 @@ private: basic_registry *reg; }; - -} - +} // namespace entt #endif diff --git a/src/entt/entity/sparse_set.hpp b/src/entt/entity/sparse_set.hpp index 53c6a02da..86a67e419 100644 --- a/src/entt/entity/sparse_set.hpp +++ b/src/entt/entity/sparse_set.hpp @@ -1,7 +1,6 @@ #ifndef ENTT_ENTITY_SPARSE_SET_HPP #define ENTT_ENTITY_SPARSE_SET_HPP - #include #include #include @@ -14,19 +13,15 @@ #include "entity.hpp" #include "fwd.hpp" - namespace entt { - /** * @cond TURN_OFF_DOXYGEN * Internal details not to be documented. */ - namespace internal { - template struct sparse_set_iterator final { using value_type = typename Traits::value_type; @@ -39,10 +34,9 @@ struct sparse_set_iterator final { sparse_set_iterator(const pointer *ref, const difference_type idx) ENTT_NOEXCEPT : packed{ref}, - index{idx} - {} + index{idx} {} - sparse_set_iterator & operator++() ENTT_NOEXCEPT { + sparse_set_iterator &operator++() ENTT_NOEXCEPT { return --index, *this; } @@ -51,7 +45,7 @@ struct sparse_set_iterator final { return ++(*this), orig; } - sparse_set_iterator & operator--() ENTT_NOEXCEPT { + sparse_set_iterator &operator--() ENTT_NOEXCEPT { return ++index, *this; } @@ -60,7 +54,7 @@ struct sparse_set_iterator final { return operator--(), orig; } - sparse_set_iterator & operator+=(const difference_type value) ENTT_NOEXCEPT { + sparse_set_iterator &operator+=(const difference_type value) ENTT_NOEXCEPT { index -= value; return *this; } @@ -70,7 +64,7 @@ struct sparse_set_iterator final { return (copy += value); } - sparse_set_iterator & operator-=(const difference_type value) ENTT_NOEXCEPT { + sparse_set_iterator &operator-=(const difference_type value) ENTT_NOEXCEPT { return (*this += -value); } @@ -124,25 +118,21 @@ private: difference_type index; }; - -} - +} // namespace internal /** * Internal details not to be documented. * @endcond */ - /*! @brief Sparse set deletion policy. */ -enum class deletion_policy: std::uint8_t { +enum class deletion_policy : std::uint8_t { /*! @brief Swap-and-pop deletion policy. */ swap_and_pop = 0u, /*! @brief In-place deletion policy. */ in_place = 1u }; - /** * @brief Basic sparse set implementation. * @@ -190,7 +180,7 @@ class basic_sparse_set { return (page < bucket && sparse[page]) ? (sparse[page] + fast_mod(pos)) : alloc_pointer{}; } - [[nodiscard]] auto & sparse_ref(const Entity entt) const { + [[nodiscard]] auto &sparse_ref(const Entity entt) const { ENTT_ASSERT(sparse_ptr(entt), "Invalid element"); const auto pos = static_cast(entity_traits::to_entity(entt)); return sparse[pos / sparse_page_v][fast_mod(pos)]; @@ -341,16 +331,14 @@ public: /*! @brief Default constructor. */ basic_sparse_set() - : basic_sparse_set{allocator_type{}} - {} + : basic_sparse_set{allocator_type{}} {} /** * @brief Constructs an empty container with a given allocator. * @param allocator The allocator to use. */ explicit basic_sparse_set(const allocator_type &allocator) - : basic_sparse_set{deletion_policy::swap_and_pop, allocator} - {} + : basic_sparse_set{deletion_policy::swap_and_pop, allocator} {} /** * @brief Constructs an empty container with the given policy and allocator. @@ -364,8 +352,7 @@ public: bucket{}, count{}, free_list{tombstone}, - mode{pol} - {} + mode{pol} {} /** * @brief Move constructor. @@ -378,8 +365,7 @@ public: bucket{std::exchange(other.bucket, size_type{})}, count{std::exchange(other.count, size_type{})}, free_list{std::exchange(other.free_list, tombstone)}, - mode{other.mode} - {} + mode{other.mode} {} /** * @brief Allocator-extended move constructor. @@ -393,8 +379,7 @@ public: bucket{std::exchange(other.bucket, size_type{})}, count{std::exchange(other.count, size_type{})}, free_list{std::exchange(other.free_list, tombstone)}, - mode{other.mode} - { + mode{other.mode} { ENTT_ASSERT(alloc_traits::is_always_equal::value || reserved.first() == other.reserved.first(), "Copying a sparse set is not allowed"); } @@ -408,7 +393,7 @@ public: * @param other The instance to move from. * @return This sparse set. */ - basic_sparse_set & operator=(basic_sparse_set &&other) ENTT_NOEXCEPT { + basic_sparse_set &operator=(basic_sparse_set &&other) ENTT_NOEXCEPT { release_memory(); propagate_on_container_move_assignment(reserved.first(), other.reserved.first()); ENTT_ASSERT(alloc_traits::is_always_equal::value || reserved.first() == other.reserved.first(), "Copying a sparse set is not allowed"); @@ -849,7 +834,7 @@ public: * @param args Arguments to forward to the sort function object, if any. */ template - void sort_n(const size_type length, Compare compare, Sort algo = Sort{}, Args &&... args) { + void sort_n(const size_type length, Compare compare, Sort algo = Sort{}, Args &&...args) { // basic no-leak guarantee (with invalid state) if sorting throws ENTT_ASSERT(!(length > count), "Length exceeds the number of elements"); compact(); @@ -885,7 +870,7 @@ public: * @param args Arguments to forward to the sort function object, if any. */ template - void sort(Compare compare, Sort algo = Sort{}, Args &&... args) { + void sort(Compare compare, Sort algo = Sort{}, Args &&...args) { sort_n(count, std::move(compare), std::move(algo), std::forward(args)...); } @@ -943,8 +928,6 @@ private: deletion_policy mode; }; - -} - +} // namespace entt #endif diff --git a/src/entt/entity/storage.hpp b/src/entt/entity/storage.hpp index 97c500a47..b3a14b80e 100644 --- a/src/entt/entity/storage.hpp +++ b/src/entt/entity/storage.hpp @@ -1,7 +1,6 @@ #ifndef ENTT_ENTITY_STORAGE_HPP #define ENTT_ENTITY_STORAGE_HPP - #include #include #include @@ -19,19 +18,15 @@ #include "fwd.hpp" #include "sparse_set.hpp" - namespace entt { - /** * @cond TURN_OFF_DOXYGEN * Internal details not to be documented. */ - namespace internal { - template class storage_iterator final { static constexpr auto packed_page_v = ENTT_PACKED_PAGE; @@ -50,10 +45,9 @@ public: storage_iterator(const data_pointer *ref, difference_type idx) ENTT_NOEXCEPT : packed{ref}, - index{idx} - {} + index{idx} {} - storage_iterator & operator++() ENTT_NOEXCEPT { + storage_iterator &operator++() ENTT_NOEXCEPT { return --index, *this; } @@ -62,7 +56,7 @@ public: return ++(*this), orig; } - storage_iterator & operator--() ENTT_NOEXCEPT { + storage_iterator &operator--() ENTT_NOEXCEPT { return ++index, *this; } @@ -71,7 +65,7 @@ public: return operator--(), orig; } - storage_iterator & operator+=(const difference_type value) ENTT_NOEXCEPT { + storage_iterator &operator+=(const difference_type value) ENTT_NOEXCEPT { index -= value; return *this; } @@ -81,7 +75,7 @@ public: return (copy += value); } - storage_iterator & operator-=(const difference_type value) ENTT_NOEXCEPT { + storage_iterator &operator-=(const difference_type value) ENTT_NOEXCEPT { return (*this += -value); } @@ -135,16 +129,13 @@ private: difference_type index; }; - -} - +} // namespace internal /** * Internal details not to be documented. * @endcond */ - /** * @brief Basic storage implementation. * @@ -191,8 +182,8 @@ class basic_storage: public basic_sparse_set; using underlying_type = basic_sparse_set>; - [[nodiscard]] auto & element_at(const std::size_t pos) const { - return packed[pos/packed_page_v][fast_mod(pos)]; + [[nodiscard]] auto &element_at(const std::size_t pos) const { + return packed[pos / packed_page_v][fast_mod(pos)]; } auto assure_at_least(const std::size_t pos) { @@ -208,7 +199,8 @@ class basic_storage: public basic_sparse_set - void construct(alloc_pointer ptr, Args &&... args) { + void construct(alloc_pointer ptr, Args &&...args) { if constexpr(std::is_aggregate_v) { alloc_traits::construct(bucket.first(), to_address(ptr), Type{std::forward(args)...}); } else { @@ -372,7 +364,8 @@ protected: ENTT_TRY { base_type::try_emplace(entt, nullptr); ENTT_ASSERT(pos == base_type::index(entt), "Misplaced component"); - } ENTT_CATCH { + } + ENTT_CATCH { std::destroy_at(std::addressof(element_at(pos))); ENTT_THROW; } @@ -407,8 +400,7 @@ public: basic_storage() : base_type{deletion_policy{comp_traits::in_place_delete::value}}, bucket{allocator_type{}, size_type{}}, - packed{} - {} + packed{} {} /** * @brief Constructs an empty storage with a given allocator. @@ -417,8 +409,7 @@ public: explicit basic_storage(const allocator_type &allocator) : base_type{deletion_policy{comp_traits::in_place_delete::value}, allocator}, bucket{allocator, size_type{}}, - packed{} - {} + packed{} {} /** * @brief Move constructor. @@ -427,8 +418,7 @@ public: basic_storage(basic_storage &&other) ENTT_NOEXCEPT : base_type{std::move(other)}, bucket{std::move(other.bucket.first()), std::exchange(other.bucket.second(), size_type{})}, - packed{std::exchange(other.packed, alloc_ptr_pointer{})} - {} + packed{std::exchange(other.packed, alloc_ptr_pointer{})} {} /** * @brief Allocator-extended move constructor. @@ -438,8 +428,7 @@ public: basic_storage(basic_storage &&other, const allocator_type &allocator) ENTT_NOEXCEPT : base_type{std::move(other), allocator}, bucket{allocator, std::exchange(other.bucket.second(), size_type{})}, - packed{std::exchange(other.packed, alloc_ptr_pointer{})} - { + packed{std::exchange(other.packed, alloc_ptr_pointer{})} { ENTT_ASSERT(alloc_traits::is_always_equal::value || bucket.first() == other.bucket.first(), "Copying a storage is not allowed"); } @@ -453,7 +442,7 @@ public: * @param other The instance to move from. * @return This storage. */ - basic_storage & operator=(basic_storage &&other) ENTT_NOEXCEPT { + basic_storage &operator=(basic_storage &&other) ENTT_NOEXCEPT { release_memory(); base_type::operator=(std::move(other)); propagate_on_container_move_assignment(bucket.first(), other.bucket.first()); @@ -619,12 +608,12 @@ public: * @param entt A valid identifier. * @return The object assigned to the entity. */ - [[nodiscard]] const value_type & get(const entity_type entt) const ENTT_NOEXCEPT { + [[nodiscard]] const value_type &get(const entity_type entt) const ENTT_NOEXCEPT { return element_at(base_type::index(entt)); } /*! @copydoc get */ - [[nodiscard]] value_type & get(const entity_type entt) ENTT_NOEXCEPT { + [[nodiscard]] value_type &get(const entity_type entt) ENTT_NOEXCEPT { return const_cast(std::as_const(*this).get(entt)); } @@ -662,7 +651,7 @@ public: * @return A reference to the newly created object. */ template - value_type & emplace(const entity_type entt, Args &&... args) { + value_type &emplace(const entity_type entt, Args &&...args) { const auto pos = base_type::slot(); alloc_pointer elem = assure_at_least(pos); construct(elem, std::forward(args)...); @@ -670,7 +659,8 @@ public: ENTT_TRY { base_type::try_emplace(entt, nullptr); ENTT_ASSERT(pos == base_type::index(entt), "Misplaced component"); - } ENTT_CATCH { + } + ENTT_CATCH { std::destroy_at(std::addressof(element_at(pos))); ENTT_THROW; } @@ -686,7 +676,7 @@ public: * @return A reference to the updated instance. */ template - value_type & patch(const entity_type entt, Func &&... func) { + value_type &patch(const entity_type entt, Func &&...func) { const auto idx = base_type::index(entt); auto &elem = element_at(idx); (std::forward(func)(elem), ...); @@ -733,12 +723,10 @@ private: alloc_ptr_pointer packed; }; - /*! @copydoc basic_storage */ template class basic_storage>> - : public basic_sparse_set::template rebind_alloc> -{ + : public basic_sparse_set::template rebind_alloc> { using allocator_traits = std::allocator_traits; using comp_traits = component_traits; @@ -756,16 +744,14 @@ public: /*! @brief Default constructor. */ basic_storage() - : base_type{deletion_policy{comp_traits::in_place_delete::value}} - {} + : base_type{deletion_policy{comp_traits::in_place_delete::value}} {} /** * @brief Constructs an empty container with a given allocator. * @param allocator The allocator to use. */ explicit basic_storage(const allocator_type &allocator) - : base_type{deletion_policy{comp_traits::in_place_delete::value}, allocator} - {} + : base_type{deletion_policy{comp_traits::in_place_delete::value}, allocator} {} /** * @brief Move constructor. @@ -778,7 +764,7 @@ public: * @param other The instance to move from. * @return This storage. */ - basic_storage & operator=(basic_storage &&other) ENTT_NOEXCEPT = default; + basic_storage &operator=(basic_storage &&other) ENTT_NOEXCEPT = default; /** * @brief Returns the associated allocator. @@ -828,7 +814,7 @@ public: * @param args Parameters to use to construct an object for the entity. */ template - void emplace(const entity_type entt, Args &&... args) { + void emplace(const entity_type entt, Args &&...args) { [[maybe_unused]] const value_type elem{std::forward(args)...}; base_type::try_emplace(entt, nullptr); } @@ -840,7 +826,7 @@ public: * @param func Valid function objects. */ template - void patch([[maybe_unused]] const entity_type entt, Func &&... func) { + void patch([[maybe_unused]] const entity_type entt, Func &&...func) { ENTT_ASSERT(base_type::contains(entt), "Storage does not contain entity"); (std::forward(func)(), ...); } @@ -866,7 +852,6 @@ public: } }; - /** * @brief Mixin type to use to wrap basic storage classes. * @tparam Type The type of the underlying storage. @@ -891,7 +876,7 @@ struct storage_adapter_mixin: Type { * @return A reference to the newly created object. */ template - decltype(auto) emplace(basic_registry &, const entity_type entt, Args &&... args) { + decltype(auto) emplace(basic_registry &, const entity_type entt, Args &&...args) { return Type::emplace(entt, std::forward(args)...); } @@ -903,7 +888,7 @@ struct storage_adapter_mixin: Type { * @return A reference to the patched instance. */ template - decltype(auto) patch(basic_registry &, const entity_type entt, Func &&... func) { + decltype(auto) patch(basic_registry &, const entity_type entt, Func &&...func) { return Type::patch(entt, std::forward(func)...); } @@ -918,12 +903,11 @@ struct storage_adapter_mixin: Type { * entities. */ template - void insert(basic_registry &, It first, It last, Args &&... args) { + void insert(basic_registry &, It first, It last, Args &&...args) { Type::insert(std::move(first), std::move(last), std::forward(args)...); } }; - /** * @brief Mixin type to use to add signal support to storage types. * @tparam Type The type of the underlying storage. @@ -1034,7 +1018,7 @@ public: * @return A reference to the newly created object. */ template - decltype(auto) emplace(basic_registry &owner, const entity_type entt, Args &&... args) { + decltype(auto) emplace(basic_registry &owner, const entity_type entt, Args &&...args) { Type::emplace(entt, std::forward(args)...); construction.publish(owner, entt); return this->get(entt); @@ -1049,7 +1033,7 @@ public: * @return A reference to the patched instance. */ template - decltype(auto) patch(basic_registry &owner, const entity_type entt, Func &&... func) { + decltype(auto) patch(basic_registry &owner, const entity_type entt, Func &&...func) { Type::patch(entt, std::forward(func)...); update.publish(owner, entt); return this->get(entt); @@ -1067,7 +1051,7 @@ public: * entities. */ template - void insert(basic_registry &owner, It first, It last, Args &&... args) { + void insert(basic_registry &owner, It first, It last, Args &&...args) { Type::insert(first, last, std::forward(args)...); if(!construction.empty()) { @@ -1083,7 +1067,6 @@ private: sigh &, const entity_type)> update{}; }; - /** * @brief Provides a common way to access certain properties of storage types. * @tparam Entity A valid entity type (see entt_traits for more details). @@ -1095,8 +1078,6 @@ struct storage_traits { using storage_type = sigh_storage_mixin>; }; - -} - +} // namespace entt #endif diff --git a/src/entt/entity/utility.hpp b/src/entt/entity/utility.hpp index 2d839e422..902805db5 100644 --- a/src/entt/entity/utility.hpp +++ b/src/entt/entity/utility.hpp @@ -1,13 +1,10 @@ #ifndef ENTT_ENTITY_UTILITY_HPP #define ENTT_ENTITY_UTILITY_HPP - #include "../core/type_traits.hpp" - namespace entt { - /** * @brief Alias for exclusion lists. * @tparam Type List of types. @@ -15,7 +12,6 @@ namespace entt { template struct exclude_t: type_list {}; - /** * @brief Variable template for exclusion lists. * @tparam Type List of types. @@ -23,14 +19,12 @@ struct exclude_t: type_list {}; template inline constexpr exclude_t exclude{}; - /** * @brief Alias for lists of observed components. * @tparam Type List of types. */ template -struct get_t: type_list{}; - +struct get_t: type_list {}; /** * @brief Variable template for lists of observed components. @@ -39,14 +33,12 @@ struct get_t: type_list{}; template inline constexpr get_t get{}; - /** * @brief Alias for lists of owned components. * @tparam Type List of types. */ template -struct owned_t: type_list{}; - +struct owned_t: type_list {}; /** * @brief Variable template for lists of owned components. @@ -55,8 +47,6 @@ struct owned_t: type_list{}; template inline constexpr owned_t owned{}; - -} - +} // namespace entt #endif diff --git a/src/entt/entity/view.hpp b/src/entt/entity/view.hpp index 15e6cc0d6..6f31bc7b5 100644 --- a/src/entt/entity/view.hpp +++ b/src/entt/entity/view.hpp @@ -1,13 +1,12 @@ #ifndef ENTT_ENTITY_VIEW_HPP #define ENTT_ENTITY_VIEW_HPP - -#include -#include -#include -#include #include +#include +#include +#include #include +#include #include "../config/config.h" #include "../core/type_traits.hpp" #include "component.hpp" @@ -17,19 +16,15 @@ #include "storage.hpp" #include "utility.hpp" - namespace entt { - /** * @cond TURN_OFF_DOXYGEN * Internal details not to be documented. */ - namespace internal { - template class iterable_storage final { using storage_type = constness_as_t>::storage_type, Component>; @@ -45,10 +40,9 @@ class iterable_storage final { template iterable_storage_iterator(It... from, Discard...) ENTT_NOEXCEPT - : it{from...} - {} + : it{from...} {} - iterable_storage_iterator & operator++() ENTT_NOEXCEPT { + iterable_storage_iterator &operator++() ENTT_NOEXCEPT { return (++std::get(it), ...), *this; } @@ -58,7 +52,7 @@ class iterable_storage final { } [[nodiscard]] reference operator*() const ENTT_NOEXCEPT { - return { *std::get(it)... }; + return {*std::get(it)...}; } [[nodiscard]] bool operator==(const iterable_storage_iterator &other) const ENTT_NOEXCEPT { @@ -77,17 +71,14 @@ public: using iterator = std::conditional_t< ignore_as_empty_v>, iterable_storage_iterator, - iterable_storage_iterator().begin())> - >; + iterable_storage_iterator().begin())>>; using reverse_iterator = std::conditional_t< ignore_as_empty_v>, iterable_storage_iterator, - iterable_storage_iterator().rbegin())> - >; + iterable_storage_iterator().rbegin())>>; iterable_storage(storage_type &ref) - : pool{&ref} - {} + : pool{&ref} {} [[nodiscard]] iterator begin() const ENTT_NOEXCEPT { return iterator{pool->basic_common_type::begin(), pool->begin()}; @@ -106,18 +97,17 @@ public: } private: - storage_type * const pool; + storage_type *const pool; }; - template class view_iterator final { static constexpr auto is_multi_type_v = ((Component + Exclude) != 0u); [[nodiscard]] bool valid() const { return (is_multi_type_v || (*it != tombstone)) - && std::apply([entt = *it](const auto *... curr) { return (curr->contains(entt) && ...); }, pools) - && std::apply([entt = *it](const auto *... curr) { return (!curr->contains(entt) && ...); }, filter); + && std::apply([entt = *it](const auto *...curr) { return (curr->contains(entt) && ...); }, pools) + && std::apply([entt = *it](const auto *...curr) { return (!curr->contains(entt) && ...); }, filter); } public: @@ -133,22 +123,20 @@ public: last{}, it{}, pools{}, - filter{} - {} + filter{} {} view_iterator(It from, It to, It curr, std::array all_of, std::array none_of) ENTT_NOEXCEPT : first{from}, last{to}, it{curr}, pools{all_of}, - filter{none_of} - { + filter{none_of} { if(it != last && !valid()) { ++(*this); } } - view_iterator & operator++() ENTT_NOEXCEPT { + view_iterator &operator++() ENTT_NOEXCEPT { while(++it != last && !valid()) { continue; } return *this; } @@ -158,7 +146,7 @@ public: return ++(*this), orig; } - view_iterator & operator--() ENTT_NOEXCEPT { + view_iterator &operator--() ENTT_NOEXCEPT { while(--it != first && !valid()) { continue; } return *this; } @@ -192,16 +180,13 @@ private: std::array filter; }; - -} - +} // namespace internal /** * Internal details not to be documented. * @endcond */ - /** * @brief View implementation. * @@ -211,7 +196,6 @@ private: template class basic_view; - /** * @brief Multi component view. * @@ -264,10 +248,9 @@ class basic_view, exclude_t> { iterable_iterator(It from, const basic_view *parent) ENTT_NOEXCEPT : it{from}, - view{parent} - {} + view{parent} {} - iterable_iterator & operator++() ENTT_NOEXCEPT { + iterable_iterator &operator++() ENTT_NOEXCEPT { return ++it, *this; } @@ -298,31 +281,30 @@ class basic_view, exclude_t> { using reverse_iterator = iterable_iterator>; iterable(const basic_view &parent) - : view{parent} - {} + : view{parent} {} [[nodiscard]] iterator begin() const ENTT_NOEXCEPT { - return { view.begin(), &view }; + return {view.begin(), &view}; } [[nodiscard]] iterator end() const ENTT_NOEXCEPT { - return { view.end(), &view }; + return {view.end(), &view}; } [[nodiscard]] reverse_iterator rbegin() const ENTT_NOEXCEPT { - return { view.rbegin(), &view }; + return {view.rbegin(), &view}; } [[nodiscard]] reverse_iterator rend() const ENTT_NOEXCEPT { - return { view.rend(), &view }; + return {view.rend(), &view}; } private: const basic_view view; }; - [[nodiscard]] const auto * candidate() const ENTT_NOEXCEPT { - return (std::min)({ static_cast(std::get *>(pools))... }, [](const auto *lhs, const auto *rhs) { + [[nodiscard]] const auto *candidate() const ENTT_NOEXCEPT { + return (std::min)({static_cast(std::get *>(pools))...}, [](const auto *lhs, const auto *rhs) { return lhs->size() < rhs->size(); }); } @@ -366,19 +348,17 @@ public: basic_view() ENTT_NOEXCEPT : pools{}, filter{}, - view{} - {} + view{} {} /** * @brief Constructs a multi-type view from a set of storage classes. * @param component The storage for the types to iterate. * @param epool The storage for the types used to filter the view. */ - basic_view(storage_type &... component, const storage_type &... epool) ENTT_NOEXCEPT + basic_view(storage_type &...component, const storage_type &...epool) ENTT_NOEXCEPT : pools{&component...}, filter{&epool...}, - view{candidate()} - {} + view{candidate()} {} /** * @brief Creates a new view driven by a given type in its iterations. @@ -507,7 +487,7 @@ public: */ [[nodiscard]] bool contains(const entity_type entt) const { return (std::get *>(pools)->contains(entt) && ...) - && std::apply([entt](const auto *... curr) { return (!curr->contains(entt) && ...); }, filter); + && std::apply([entt](const auto *...curr) { return (!curr->contains(entt) && ...); }, filter); } /** @@ -583,9 +563,8 @@ public: void each(Func func) const { for(const auto curr: internal::iterable_storage{*std::get *>(pools)}) { if((is_multi_type_v || (std::get<0>(curr) != tombstone)) - && ((std::is_same_v || std::get *>(pools)->contains(std::get<0>(curr))) && ...) - && std::apply([entt = std::get<0>(curr)](const auto *... cpool) { return (!cpool->contains(entt) && ...); }, filter)) - { + && ((std::is_same_v || std::get *>(pools)->contains(std::get<0>(curr))) && ...) + && std::apply([entt = std::get<0>(curr)](const auto *...cpool) { return (!cpool->contains(entt) && ...); }, filter)) { if constexpr(is_applicable_v{}, std::declval().get({})))>) { std::apply(func, std::tuple_cat(std::make_tuple(std::get<0>(curr)), dispatch_get(curr)...)); } else { @@ -642,21 +621,18 @@ public: [[nodiscard]] auto operator|(const basic_view, exclude_t> &other) const ENTT_NOEXCEPT { using view_type = basic_view, exclude_t>; return std::make_from_tuple(std::tuple_cat( - std::apply([](auto *... curr) { return std::forward_as_tuple(*curr...); }, pools), - std::apply([](auto *... curr) { return std::forward_as_tuple(*curr...); }, other.pools), - std::apply([](const auto *... curr) { return std::forward_as_tuple(static_cast &>(*curr)...); }, filter), - std::apply([](const auto *... curr) { return std::forward_as_tuple(static_cast &>(*curr)...); }, other.filter) - )); + std::apply([](auto *...curr) { return std::forward_as_tuple(*curr...); }, pools), + std::apply([](auto *...curr) { return std::forward_as_tuple(*curr...); }, other.pools), + std::apply([](const auto *...curr) { return std::forward_as_tuple(static_cast &>(*curr)...); }, filter), + std::apply([](const auto *...curr) { return std::forward_as_tuple(static_cast &>(*curr)...); }, other.filter))); } - private: std::tuple *...> pools; std::array filter; const basic_common_type *view; }; - /** * @brief Single component view specialization. * @@ -689,8 +665,7 @@ private: * @tparam Component Type of component iterated by the view. */ template -class basic_view, exclude_t<>, std::void_t>>> -> { +class basic_view, exclude_t<>, std::void_t>>>> { template friend class basic_view; @@ -713,8 +688,7 @@ public: /*! @brief Default constructor to use to create empty, invalid views. */ basic_view() ENTT_NOEXCEPT : pools{}, - filter{} - {} + filter{} {} /** * @brief Constructs a single-type view from a storage class. @@ -722,8 +696,7 @@ public: */ basic_view(storage_type &ref) ENTT_NOEXCEPT : pools{&ref}, - filter{} - {} + filter{} {} /** * @brief Returns the number of entities that have the given component. @@ -981,10 +954,9 @@ public: [[nodiscard]] auto operator|(const basic_view, exclude_t> &other) const ENTT_NOEXCEPT { using view_type = basic_view, exclude_t>; return std::make_from_tuple(std::tuple_cat( - std::apply([](auto *... curr) { return std::forward_as_tuple(*curr...); }, pools), - std::apply([](auto *... curr) { return std::forward_as_tuple(*curr...); }, other.pools), - std::apply([](const auto *... curr) { return std::forward_as_tuple(static_cast &>(*curr)...); }, other.filter) - )); + std::apply([](auto *...curr) { return std::forward_as_tuple(*curr...); }, pools), + std::apply([](auto *...curr) { return std::forward_as_tuple(*curr...); }, other.pools), + std::apply([](const auto *...curr) { return std::forward_as_tuple(static_cast &>(*curr)...); }, other.filter))); } private: @@ -992,17 +964,14 @@ private: std::tuple<> filter; }; - /** * @brief Deduction guide. * @tparam Storage Type of storage classes used to create the view. * @param storage The storage for the types to iterate. */ template -basic_view(Storage &... storage) -> basic_view, get_t...>, exclude_t<>>; - - -} +basic_view(Storage &...storage) -> basic_view, get_t...>, exclude_t<>>; +} // namespace entt #endif diff --git a/src/entt/locator/locator.hpp b/src/entt/locator/locator.hpp index becceb112..26221340d 100644 --- a/src/entt/locator/locator.hpp +++ b/src/entt/locator/locator.hpp @@ -1,15 +1,12 @@ #ifndef ENTT_LOCATOR_LOCATOR_HPP #define ENTT_LOCATOR_LOCATOR_HPP - #include #include #include "../config/config.h" - namespace entt { - /** * @brief Service locator, nothing more. * @@ -67,7 +64,7 @@ struct service_locator { * * @return A reference to the service implementation currently set, if any. */ - [[nodiscard]] static Service & ref() ENTT_NOEXCEPT { + [[nodiscard]] static Service &ref() ENTT_NOEXCEPT { return *service; } @@ -78,7 +75,7 @@ struct service_locator { * @param args Parameters to use to construct the service. */ template - static void set(Args &&... args) { + static void set(Args &&...args) { service = std::make_shared(std::forward(args)...); } @@ -104,8 +101,6 @@ private: inline static std::shared_ptr service = nullptr; }; - -} - +} // namespace entt #endif diff --git a/src/entt/meta/adl_pointer.hpp b/src/entt/meta/adl_pointer.hpp index 39e747ba5..5bb768ac7 100644 --- a/src/entt/meta/adl_pointer.hpp +++ b/src/entt/meta/adl_pointer.hpp @@ -1,10 +1,8 @@ #ifndef ENTT_META_ADL_POINTER_HPP #define ENTT_META_ADL_POINTER_HPP - namespace entt { - /** * @brief ADL based lookup function for dereferencing meta pointer-like types. * @tparam Type Element type. @@ -16,7 +14,6 @@ decltype(auto) dereference_meta_pointer_like(const Type &value) { return *value; } - /** * @brief Fake ADL based lookup function for meta pointer-like types. * @tparam Type Element type. @@ -33,8 +30,6 @@ struct adl_meta_pointer_like { } }; - -} - +} // namespace entt #endif diff --git a/src/entt/meta/container.hpp b/src/entt/meta/container.hpp index f360bacce..c4aeab397 100644 --- a/src/entt/meta/container.hpp +++ b/src/entt/meta/container.hpp @@ -1,7 +1,6 @@ #ifndef ENTT_META_CONTAINER_HPP #define ENTT_META_CONTAINER_HPP - #include #include #include @@ -12,33 +11,27 @@ #include "meta.hpp" #include "type_traits.hpp" - namespace entt { - /** * @cond TURN_OFF_DOXYGEN * Internal details not to be documented. */ - namespace internal { - template struct is_dynamic_sequence_container: std::false_type {}; template struct is_dynamic_sequence_container>: std::true_type {}; - template struct is_key_only_meta_associative_container: std::true_type {}; template struct is_key_only_meta_associative_container>: std::false_type {}; - template struct basic_meta_sequence_container_traits { using iterator = meta_sequence_container::iterator; @@ -50,7 +43,7 @@ struct basic_meta_sequence_container_traits { [[nodiscard]] static bool resize([[maybe_unused]] any &container, [[maybe_unused]] size_type sz) { if constexpr(is_dynamic_sequence_container::value) { - if(auto * const cont = any_cast(&container); cont) { + if(auto *const cont = any_cast(&container); cont) { cont->resize(sz); return true; } @@ -61,7 +54,7 @@ struct basic_meta_sequence_container_traits { [[nodiscard]] static bool clear([[maybe_unused]] any &container) { if constexpr(is_dynamic_sequence_container::value) { - if(auto * const cont = any_cast(&container); cont) { + if(auto *const cont = any_cast(&container); cont) { cont->clear(); return true; } @@ -71,7 +64,7 @@ struct basic_meta_sequence_container_traits { } [[nodiscard]] static iterator begin(any &container) { - if(auto * const cont = any_cast(&container); cont) { + if(auto *const cont = any_cast(&container); cont) { return iterator{std::begin(*cont)}; } @@ -79,7 +72,7 @@ struct basic_meta_sequence_container_traits { } [[nodiscard]] static iterator end(any &container) { - if(auto * const cont = any_cast(&container); cont) { + if(auto *const cont = any_cast(&container); cont) { return iterator{std::end(*cont)}; } @@ -88,7 +81,7 @@ struct basic_meta_sequence_container_traits { [[nodiscard]] static iterator insert([[maybe_unused]] any &container, [[maybe_unused]] iterator it, [[maybe_unused]] meta_any &value) { if constexpr(is_dynamic_sequence_container::value) { - if(auto * const cont = any_cast(&container); cont) { + if(auto *const cont = any_cast(&container); cont) { // this abomination is necessary because only on macos value_type and const_reference are different types for std::vector if(value.allow_cast() || value.allow_cast()) { const auto *element = value.try_cast>(); @@ -102,7 +95,7 @@ struct basic_meta_sequence_container_traits { [[nodiscard]] static iterator erase([[maybe_unused]] any &container, [[maybe_unused]] iterator it) { if constexpr(is_dynamic_sequence_container::value) { - if(auto * const cont = any_cast(&container); cont) { + if(auto *const cont = any_cast(&container); cont) { return iterator{cont->erase(any_cast(it.base()))}; } } @@ -111,7 +104,7 @@ struct basic_meta_sequence_container_traits { } [[nodiscard]] static meta_any get(any &container, size_type pos) { - if(auto * const cont = any_cast(&container); cont) { + if(auto *const cont = any_cast(&container); cont) { return meta_any{std::in_place_type, (*cont)[pos]}; } @@ -119,7 +112,6 @@ struct basic_meta_sequence_container_traits { } }; - template struct basic_meta_associative_container_traits { using iterator = meta_associative_container::iterator; @@ -132,7 +124,7 @@ struct basic_meta_associative_container_traits { } [[nodiscard]] static bool clear(any &container) { - if(auto * const cont = any_cast(&container); cont) { + if(auto *const cont = any_cast(&container); cont) { cont->clear(); return true; } @@ -141,7 +133,7 @@ struct basic_meta_associative_container_traits { } [[nodiscard]] static iterator begin(any &container) { - if(auto * const cont = any_cast(&container); cont) { + if(auto *const cont = any_cast(&container); cont) { return iterator{std::integral_constant{}, cont->begin()}; } @@ -149,7 +141,7 @@ struct basic_meta_associative_container_traits { } [[nodiscard]] static iterator end(any &container) { - if(auto * const cont = any_cast(&container); cont) { + if(auto *const cont = any_cast(&container); cont) { return iterator{std::integral_constant{}, cont->end()}; } @@ -157,7 +149,7 @@ struct basic_meta_associative_container_traits { } [[nodiscard]] static bool insert(any &container, meta_any &key, [[maybe_unused]] meta_any &value) { - if(auto * const cont = any_cast(&container); cont && key.allow_cast()) { + if(auto *const cont = any_cast(&container); cont && key.allow_cast()) { if constexpr(is_key_only_meta_associative_container::value) { return cont->insert(key.cast()).second; } else { @@ -171,7 +163,7 @@ struct basic_meta_associative_container_traits { } [[nodiscard]] static bool erase(any &container, meta_any &key) { - if(auto * const cont = any_cast(&container); cont && key.allow_cast()) { + if(auto *const cont = any_cast(&container); cont && key.allow_cast()) { return (cont->erase(key.cast()) != cont->size()); } @@ -180,7 +172,7 @@ struct basic_meta_associative_container_traits { [[nodiscard]] static iterator find(any &container, meta_any &key) { if(key.allow_cast()) { - if(auto * const cont = any_cast(&container); cont) { + if(auto *const cont = any_cast(&container); cont) { return iterator{std::integral_constant{}, cont->find(key.cast())}; } @@ -191,16 +183,13 @@ struct basic_meta_associative_container_traits { } }; - -} - +} // namespace internal /** * Internal details not to be documented. * @endcond */ - /** * @brief Meta sequence container traits for `std::vector`s of any type. * @tparam Type The type of elements. @@ -208,9 +197,7 @@ struct basic_meta_associative_container_traits { */ template struct meta_sequence_container_traits> - : internal::basic_meta_sequence_container_traits> -{}; - + : internal::basic_meta_sequence_container_traits> {}; /** * @brief Meta sequence container traits for `std::array`s of any type. @@ -219,9 +206,7 @@ struct meta_sequence_container_traits> */ template struct meta_sequence_container_traits> - : internal::basic_meta_sequence_container_traits> -{}; - + : internal::basic_meta_sequence_container_traits> {}; /** * @brief Meta associative container traits for `std::map`s of any type. @@ -231,9 +216,7 @@ struct meta_sequence_container_traits> */ template struct meta_associative_container_traits> - : internal::basic_meta_associative_container_traits> -{}; - + : internal::basic_meta_associative_container_traits> {}; /** * @brief Meta associative container traits for `std::unordered_map`s of any @@ -244,9 +227,7 @@ struct meta_associative_container_traits> */ template struct meta_associative_container_traits> - : internal::basic_meta_associative_container_traits> -{}; - + : internal::basic_meta_associative_container_traits> {}; /** * @brief Meta associative container traits for `std::set`s of any type. @@ -255,9 +236,7 @@ struct meta_associative_container_traits */ template struct meta_associative_container_traits> - : internal::basic_meta_associative_container_traits> -{}; - + : internal::basic_meta_associative_container_traits> {}; /** * @brief Meta associative container traits for `std::unordered_set`s of any @@ -267,11 +246,8 @@ struct meta_associative_container_traits> */ template struct meta_associative_container_traits> - : internal::basic_meta_associative_container_traits> -{}; - - -} + : internal::basic_meta_associative_container_traits> {}; +} // namespace entt #endif diff --git a/src/entt/meta/ctx.hpp b/src/entt/meta/ctx.hpp index 5eb1170f9..7b20c4bf1 100644 --- a/src/entt/meta/ctx.hpp +++ b/src/entt/meta/ctx.hpp @@ -1,52 +1,43 @@ #ifndef ENTT_META_CTX_HPP #define ENTT_META_CTX_HPP - -#include "../core/attribute.h" #include "../config/config.h" - +#include "../core/attribute.h" namespace entt { - /** * @cond TURN_OFF_DOXYGEN * Internal details not to be documented. */ - namespace internal { - struct meta_type_node; - struct ENTT_API meta_context { // we could use the lines below but VS2017 returns with an ICE if combined with ENTT_API despite the code being valid C++ // inline static meta_type_node *local = nullptr; // inline static meta_type_node **global = &local; - [[nodiscard]] static meta_type_node * & local() ENTT_NOEXCEPT { + [[nodiscard]] static meta_type_node *&local() ENTT_NOEXCEPT { static meta_type_node *chain = nullptr; return chain; } - [[nodiscard]] static meta_type_node ** & global() ENTT_NOEXCEPT { + [[nodiscard]] static meta_type_node **&global() ENTT_NOEXCEPT { static meta_type_node **chain = &local(); return chain; } }; - -} - +} // namespace internal /** * Internal details not to be documented. * @endcond */ - /*! @brief Opaque container for a meta context. */ struct meta_ctx { /** @@ -61,8 +52,6 @@ private: internal::meta_type_node **ctx{&internal::meta_context::local()}; }; - -} - +} // namespace entt #endif diff --git a/src/entt/meta/factory.hpp b/src/entt/meta/factory.hpp index 24b749e3d..b0777fa20 100644 --- a/src/entt/meta/factory.hpp +++ b/src/entt/meta/factory.hpp @@ -1,7 +1,6 @@ #ifndef ENTT_META_FACTORY_HPP #define ENTT_META_FACTORY_HPP - #include #include #include @@ -17,10 +16,8 @@ #include "range.hpp" #include "utility.hpp" - namespace entt { - /** * @brief Meta factory to be used for reflection purposes. * @@ -32,7 +29,6 @@ namespace entt { template class meta_factory; - /** * @brief Extended meta factory to be used for reflection purposes. * @tparam Type Reflected type for which the factory was created. @@ -49,21 +45,21 @@ class meta_factory: public meta_factory { } template - void unroll(choice_t<2>, std::tuple property, Other &&... other) { - std::apply([this](auto &&... curr) { (unroll(choice<2>, std::forward(curr)), ...); }, property); + void unroll(choice_t<2>, std::tuple property, Other &&...other) { + std::apply([this](auto &&...curr) { (unroll(choice<2>, std::forward(curr)), ...); }, property); unroll(choice<2>, std::forward(other)...); } template - void unroll(choice_t<1>, std::pair property, Other &&... other) { + void unroll(choice_t<1>, std::pair property, Other &&...other) { assign(std::move(property.first), std::move(property.second)); - unroll(choice<2>, std::forward(other)...); + unroll(choice<2>, std::forward(other)...); } template - void unroll(choice_t<0>, Property &&property, Other &&... other) { + void unroll(choice_t<0>, Property &&property, Other &&...other) { assign(std::forward(property)); - unroll(choice<2>, std::forward(other)...); + unroll(choice<2>, std::forward(other)...); } template @@ -92,8 +88,7 @@ public: * @param target The underlying node to which to assign the properties. */ meta_factory(internal::meta_prop_node **target) ENTT_NOEXCEPT - : ref{target} - {} + : ref{target} {} /** * @brief Assigns a property to the last meta object created. @@ -107,7 +102,7 @@ public: * @return A meta factory for the parent type. */ template - meta_factory prop(PropertyOrKey &&property_or_key, Value &&... value) && { + meta_factory prop(PropertyOrKey &&property_or_key, Value &&...value) && { if constexpr(sizeof...(Value) == 0) { unroll(choice<3>, std::forward(property_or_key)); } else { @@ -126,7 +121,7 @@ public: * @param property Properties to assign to the last meta object created. * @return A meta factory for the parent type. */ - template + template meta_factory props(Property... property) && { unroll(choice<3>, std::forward(property)...); return {}; @@ -136,7 +131,6 @@ private: internal::meta_prop_node **ref; }; - /** * @brief Basic meta factory to be used for reflection purposes. * @tparam Type Reflected type for which the factory was created. @@ -210,8 +204,7 @@ class meta_factory { public: /*! @brief Default constructor. */ meta_factory() - : owner{internal::meta_node::resolve()} - {} + : owner{internal::meta_node::resolve()} {} /** * @brief Makes a meta type _searchable_. @@ -363,7 +356,7 @@ public: */ template auto ctor() ENTT_NOEXCEPT { - using descriptor = meta_function_helper_t; + using descriptor = meta_function_helper_t; static internal::meta_ctor_node node{ nullptr, @@ -560,7 +553,6 @@ private: internal::meta_type_node *owner; }; - /** * @brief Utility function to use for reflection. * @@ -574,12 +566,11 @@ private: */ template [[nodiscard]] auto meta() ENTT_NOEXCEPT { - auto * const node = internal::meta_node::resolve(); + auto *const node = internal::meta_node::resolve(); // extended meta factory to allow assigning properties to opaque meta types return meta_factory{&node->prop}; } - /** * @brief Resets a type and all its parts. * @@ -596,12 +587,12 @@ inline void meta_reset(const id_type id) ENTT_NOEXCEPT { for(; *curr; *curr = std::exchange((*curr)->next, nullptr)) { if constexpr(sizeof...(member) != 0u) { static_assert(sizeof...(member) == 1u, "Assert in defense of the future me"); - for(auto **sub = (&((*curr)->*member), ...); *sub; *sub = std::exchange((*sub)->next, nullptr)); + for(auto **sub = (&((*curr)->*member), ...); *sub; *sub = std::exchange((*sub)->next, nullptr)) { continue; } } } }; - for(auto** it = internal::meta_context::global(); *it; it = &(*it)->next) { + for(auto **it = internal::meta_context::global(); *it; it = &(*it)->next) { if(auto *node = *it; node->id == id) { clear_chain(&node->prop); clear_chain(&node->base); @@ -631,7 +622,6 @@ void meta_reset() ENTT_NOEXCEPT { meta_reset(internal::meta_node::resolve()->id); } - /** * @brief Resets all searchable types. * @@ -643,8 +633,6 @@ inline void meta_reset() ENTT_NOEXCEPT { } } - -} - +} // namespace entt #endif diff --git a/src/entt/meta/fwd.hpp b/src/entt/meta/fwd.hpp index 78056ce9b..fa0c57ac1 100644 --- a/src/entt/meta/fwd.hpp +++ b/src/entt/meta/fwd.hpp @@ -1,35 +1,24 @@ #ifndef ENTT_META_FWD_HPP #define ENTT_META_FWD_HPP - namespace entt { - class meta_sequence_container; - class meta_associative_container; - class meta_any; - struct meta_handle; - struct meta_prop; - struct meta_data; - struct meta_func; - class meta_type; - -} - +} // namespace entt #endif diff --git a/src/entt/meta/meta.hpp b/src/entt/meta/meta.hpp index 0e4cdae54..ea8219537 100644 --- a/src/entt/meta/meta.hpp +++ b/src/entt/meta/meta.hpp @@ -1,7 +1,6 @@ #ifndef ENTT_META_META_HPP #define ENTT_META_META_HPP - #include #include #include @@ -10,23 +9,20 @@ #include "../config/config.h" #include "../core/any.hpp" #include "../core/fwd.hpp" -#include "../core/utility.hpp" #include "../core/type_info.hpp" #include "../core/type_traits.hpp" +#include "../core/utility.hpp" #include "adl_pointer.hpp" #include "ctx.hpp" #include "node.hpp" #include "range.hpp" #include "type_traits.hpp" - namespace entt { - class meta_any; class meta_type; - /*! @brief Proxy object for sequence containers. */ class meta_sequence_container { class meta_iterator; @@ -56,8 +52,7 @@ public: insert_fn{&meta_sequence_container_traits::insert}, erase_fn{&meta_sequence_container_traits::erase}, get_fn{&meta_sequence_container_traits::get}, - storage{std::move(instance)} - {} + storage{std::move(instance)} {} [[nodiscard]] inline meta_type value_type() const ENTT_NOEXCEPT; [[nodiscard]] inline size_type size() const ENTT_NOEXCEPT; @@ -72,18 +67,17 @@ public: private: internal::meta_type_node *value_type_node = nullptr; - size_type(* size_fn)(const any &) ENTT_NOEXCEPT = nullptr; - bool(* resize_fn)(any &, size_type) = nullptr; - bool(* clear_fn)(any &) = nullptr; - iterator(* begin_fn)(any &) = nullptr; - iterator(* end_fn)(any &) = nullptr; - iterator(* insert_fn)(any &, iterator, meta_any &) = nullptr; - iterator(* erase_fn)(any &, iterator) = nullptr; - meta_any(* get_fn)(any &, size_type) = nullptr; + size_type (*size_fn)(const any &) ENTT_NOEXCEPT = nullptr; + bool (*resize_fn)(any &, size_type) = nullptr; + bool (*clear_fn)(any &) = nullptr; + iterator (*begin_fn)(any &) = nullptr; + iterator (*end_fn)(any &) = nullptr; + iterator (*insert_fn)(any &, iterator, meta_any &) = nullptr; + iterator (*erase_fn)(any &, iterator) = nullptr; + meta_any (*get_fn)(any &, size_type) = nullptr; any storage{}; }; - /*! @brief Proxy object for associative containers. */ class meta_associative_container { class meta_iterator; @@ -115,8 +109,7 @@ public: insert_fn{&meta_associative_container_traits::insert}, erase_fn{&meta_associative_container_traits::erase}, find_fn{&meta_associative_container_traits::find}, - storage{std::move(instance)} - { + storage{std::move(instance)} { if constexpr(!meta_associative_container_traits::key_only) { mapped_type_node = internal::meta_node>>::resolve(); } @@ -140,21 +133,22 @@ private: internal::meta_type_node *key_type_node = nullptr; internal::meta_type_node *mapped_type_node = nullptr; internal::meta_type_node *value_type_node = nullptr; - size_type(* size_fn)(const any &) ENTT_NOEXCEPT = nullptr; - bool(* clear_fn)(any &) = nullptr; - iterator(* begin_fn)(any &) = nullptr; - iterator(* end_fn)(any &) = nullptr; - bool(* insert_fn)(any &, meta_any &, meta_any &) = nullptr; - bool(* erase_fn)(any &, meta_any &) = nullptr; - iterator(* find_fn)(any &, meta_any &) = nullptr; + size_type (*size_fn)(const any &) ENTT_NOEXCEPT = nullptr; + bool (*clear_fn)(any &) = nullptr; + iterator (*begin_fn)(any &) = nullptr; + iterator (*end_fn)(any &) = nullptr; + bool (*insert_fn)(any &, meta_any &, meta_any &) = nullptr; + bool (*erase_fn)(any &, meta_any &) = nullptr; + iterator (*find_fn)(any &, meta_any &) = nullptr; any storage{}; }; - /*! @brief Opaque wrapper for values of any type. */ class meta_any { - enum class operation: std::uint8_t { - DEREF, SEQ, ASSOC + enum class operation : std::uint8_t { + DEREF, + SEQ, + ASSOC }; using vtable_type = void(const operation, const any &, void *); @@ -177,12 +171,12 @@ class meta_any { break; case operation::SEQ: if constexpr(is_complete_v>) { - *static_cast(to) = { std::in_place_type, std::move(const_cast(from)) }; + *static_cast(to) = {std::in_place_type, std::move(const_cast(from))}; } break; case operation::ASSOC: if constexpr(is_complete_v>) { - *static_cast(to) = { std::in_place_type, std::move(const_cast(from)) }; + *static_cast(to) = {std::in_place_type, std::move(const_cast(from))}; } break; } @@ -198,16 +192,14 @@ class meta_any { meta_any(const meta_any &other, any ref) ENTT_NOEXCEPT : storage{std::move(ref)}, node{storage ? other.node : nullptr}, - vtable{storage ? other.vtable : &basic_vtable} - {} + vtable{storage ? other.vtable : &basic_vtable} {} public: /*! @brief Default constructor. */ meta_any() ENTT_NOEXCEPT : storage{}, node{}, - vtable{&basic_vtable} - {} + vtable{&basic_vtable} {} /** * @brief Constructs a wrapper by directly initializing the new object. @@ -216,11 +208,10 @@ public: * @param args Parameters to use to construct the instance. */ template - explicit meta_any(std::in_place_type_t, Args &&... args) + explicit meta_any(std::in_place_type_t, Args &&...args) : storage{std::in_place_type, std::forward(args)...}, node{internal::meta_node>>::resolve()}, - vtable{&basic_vtable>>} - {} + vtable{&basic_vtable>>} {} /** * @brief Constructs a wrapper from a given value. @@ -229,8 +220,7 @@ public: */ template, meta_any>>> meta_any(Type &&value) - : meta_any{std::in_place_type>>, std::forward(value)} - {} + : meta_any{std::in_place_type>>, std::forward(value)} {} /** * @brief Copy constructor. @@ -245,8 +235,7 @@ public: meta_any(meta_any &&other) ENTT_NOEXCEPT : storage{std::move(other.storage)}, node{std::exchange(other.node, nullptr)}, - vtable{std::exchange(other.vtable, &basic_vtable)} - {} + vtable{std::exchange(other.vtable, &basic_vtable)} {} /*! @brief Frees the internal storage, whatever it means. */ ~meta_any() { @@ -258,7 +247,7 @@ public: * @param other The instance to copy from. * @return This meta any object. */ - meta_any & operator=(const meta_any &other) { + meta_any &operator=(const meta_any &other) { release(); vtable = other.vtable; storage = other.storage; @@ -271,7 +260,7 @@ public: * @param other The instance to move from. * @return This meta any object. */ - meta_any & operator=(meta_any &&other) ENTT_NOEXCEPT { + meta_any &operator=(meta_any &&other) ENTT_NOEXCEPT { release(); vtable = std::exchange(other.vtable, &basic_vtable); storage = std::move(other.storage); @@ -302,12 +291,12 @@ public: * @brief Returns an opaque pointer to the contained instance. * @return An opaque pointer the contained instance, if any. */ - [[nodiscard]] const void * data() const ENTT_NOEXCEPT { + [[nodiscard]] const void *data() const ENTT_NOEXCEPT { return storage.data(); } /*! @copydoc data */ - [[nodiscard]] void * data() ENTT_NOEXCEPT { + [[nodiscard]] void *data() ENTT_NOEXCEPT { return storage.data(); } @@ -322,11 +311,11 @@ public: * @return A wrapper containing the returned value, if any. */ template - meta_any invoke(const id_type id, Args &&... args) const; + meta_any invoke(const id_type id, Args &&...args) const; /*! @copydoc invoke */ template - meta_any invoke(const id_type id, Args &&... args); + meta_any invoke(const id_type id, Args &&...args); /** * @brief Sets the value of a given variable. @@ -358,7 +347,7 @@ public: * @return A (possibly null) pointer to the contained instance. */ template - [[nodiscard]] const Type * try_cast() const { + [[nodiscard]] const Type *try_cast() const { if(const auto info = type_id(); node && node->info == info) { return any_cast(&storage); } else if(const auto *base = internal::visit<&internal::meta_type_node::base>([info](const auto *curr) { return curr->type->info == info; }, node); base) { @@ -370,13 +359,13 @@ public: /*! @copydoc try_cast */ template - [[nodiscard]] Type * try_cast() { + [[nodiscard]] Type *try_cast() { if(const auto info = type_id(); node && node->info == info) { return any_cast(&storage); } else if(const auto *base = internal::visit<&internal::meta_type_node::base>([info](const auto *curr) { return curr->type->info == info; }, node); base) { return static_cast(const_cast *>(base->cast(static_cast &>(storage).data()))); } - + return nullptr; } @@ -393,7 +382,7 @@ public: */ template [[nodiscard]] Type cast() const { - auto * const instance = try_cast>(); + auto *const instance = try_cast>(); ENTT_ASSERT(instance, "Invalid instance"); return static_cast(*instance); } @@ -402,7 +391,7 @@ public: template [[nodiscard]] Type cast() { // forces const on non-reference types to make them work also with wrappers for const references - auto * const instance = try_cast>(); + auto *const instance = try_cast>(); ENTT_ASSERT(instance, "Invalid instance"); return static_cast(*instance); } @@ -479,7 +468,7 @@ public: * @param args Parameters to use to construct the instance. */ template - void emplace(Args &&... args) { + void emplace(Args &&...args) { release(); vtable = &basic_vtable>>; storage.emplace(std::forward(args)...); @@ -575,7 +564,6 @@ private: vtable_type *vtable; }; - /** * @brief Checks if two wrappers differ in their content. * @param lhs A wrapper, either empty or not. @@ -586,7 +574,6 @@ private: return !(lhs == rhs); } - /** * @brief Constructs a wrapper from a given type, passing it all arguments. * @tparam Type Type of object to use to initialize the wrapper. @@ -595,11 +582,10 @@ private: * @return A properly initialized wrapper for an object of the given type. */ template -meta_any make_meta(Args &&... args) { +meta_any make_meta(Args &&...args) { return meta_any{std::in_place_type, std::forward(args)...}; } - /** * @brief Forwards its argument and avoids copies for lvalue references. * @tparam Type Type of argument to use to construct the new instance. @@ -611,7 +597,6 @@ meta_any forward_as_meta(Type &&value) { return meta_any{std::in_place_type, std::decay_t, Type>>, std::forward(value)}; } - /** * @brief Opaque pointers to instances of any type. * @@ -623,7 +608,6 @@ struct meta_handle { /*! @brief Default constructor. */ meta_handle() = default; - /*! @brief Default copy constructor, deleted on purpose. */ meta_handle(const meta_handle &) = delete; @@ -634,13 +618,13 @@ struct meta_handle { * @brief Default copy assignment operator, deleted on purpose. * @return This meta handle. */ - meta_handle & operator=(const meta_handle &) = delete; + meta_handle &operator=(const meta_handle &) = delete; /** * @brief Default move assignment operator. * @return This meta handle. */ - meta_handle & operator=(meta_handle &&) = default; + meta_handle &operator=(meta_handle &&) = default; /** * @brief Creates a handle that points to an unmanaged object. @@ -649,8 +633,7 @@ struct meta_handle { */ template, meta_handle>>> meta_handle(Type &value) ENTT_NOEXCEPT - : meta_handle{} - { + : meta_handle{} { if constexpr(std::is_same_v, meta_any>) { any = value.as_ref(); } else { @@ -670,12 +653,12 @@ struct meta_handle { * @brief Access operator for accessing the contained opaque object. * @return A wrapper that shares a reference to an unmanaged object. */ - [[nodiscard]] meta_any * operator->() { + [[nodiscard]] meta_any *operator->() { return &any; } /*! @copydoc operator-> */ - [[nodiscard]] const meta_any * operator->() const { + [[nodiscard]] const meta_any *operator->() const { return &any; } @@ -683,7 +666,6 @@ private: meta_any any; }; - /*! @brief Opaque wrapper for properties of any type. */ struct meta_prop { /*! @brief Node type. */ @@ -694,8 +676,7 @@ struct meta_prop { * @param curr The underlying node with which to construct the instance. */ meta_prop(const node_type *curr = nullptr) ENTT_NOEXCEPT - : node{curr} - {} + : node{curr} {} /** * @brief Returns the stored key as a const reference. @@ -725,7 +706,6 @@ private: const node_type *node; }; - /*! @brief Opaque wrapper for data members. */ struct meta_data { /*! @brief Node type. */ @@ -735,8 +715,7 @@ struct meta_data { /*! @copydoc meta_prop::meta_prop */ meta_data(const node_type *curr = nullptr) ENTT_NOEXCEPT - : node{curr} - {} + : node{curr} {} /*! @copydoc meta_type::id */ [[nodiscard]] id_type id() const ENTT_NOEXCEPT { @@ -844,7 +823,6 @@ private: const node_type *node; }; - /*! @brief Opaque wrapper for member functions. */ struct meta_func { /*! @brief Node type. */ @@ -854,8 +832,7 @@ struct meta_func { /*! @copydoc meta_prop::meta_prop */ meta_func(const node_type *curr = nullptr) ENTT_NOEXCEPT - : node{curr} - {} + : node{curr} {} /*! @copydoc meta_type::id */ [[nodiscard]] id_type id() const ENTT_NOEXCEPT { @@ -914,7 +891,7 @@ struct meta_func { * @param sz Number of parameters to use to invoke the function. * @return A wrapper containing the returned value, if any. */ - meta_any invoke(meta_handle instance, meta_any * const args, const size_type sz) const { + meta_any invoke(meta_handle instance, meta_any *const args, const size_type sz) const { return sz == arity() ? node->invoke(std::move(instance), args) : meta_any{}; } @@ -929,7 +906,7 @@ struct meta_func { * @return A wrapper containing the new instance, if any. */ template - meta_any invoke(meta_handle instance, Args &&... args) const { + meta_any invoke(meta_handle instance, Args &&...args) const { meta_any arguments[sizeof...(Args) + 1u]{std::forward(args)...}; return invoke(std::move(instance), arguments, sizeof...(Args)); } @@ -966,11 +943,10 @@ private: const node_type *node; }; - /*! @brief Opaque wrapper for types. */ class meta_type { template - const auto * lookup(meta_any * const args, const typename internal::meta_type_node::size_type sz, Pred pred) const { + const auto *lookup(meta_any *const args, const typename internal::meta_type_node::size_type sz, Pred pred) const { std::decay_t*Member)> candidate{}; size_type extent{sz + 1u}; bool ambiguous{}; @@ -1011,16 +987,14 @@ public: /*! @copydoc meta_prop::meta_prop */ meta_type(const node_type *curr = nullptr) ENTT_NOEXCEPT - : node{curr} - {} + : node{curr} {} /** * @brief Constructs an instance from a given base node. * @param curr The base node with which to construct the instance. */ meta_type(const base_node_type *curr) ENTT_NOEXCEPT - : node{curr ? curr->type : nullptr} - {} + : node{curr ? curr->type : nullptr} {} /** * @brief Returns the type info object of the underlying type. @@ -1220,7 +1194,7 @@ public: * @param sz Number of parameters to use to construct the instance. * @return A wrapper containing the new instance, if any. */ - [[nodiscard]] meta_any construct(meta_any * const args, const size_type sz) const { + [[nodiscard]] meta_any construct(meta_any *const args, const size_type sz) const { const auto *candidate = lookup<&node_type::ctor>(args, sz, [](const auto *) { return true; }); return candidate ? candidate->invoke(args) : ((!sz && node->default_constructor) ? node->default_constructor() : meta_any{}); } @@ -1235,7 +1209,7 @@ public: * @return A wrapper containing the new instance, if any. */ template - [[nodiscard]] meta_any construct(Args &&... args) const { + [[nodiscard]] meta_any construct(Args &&...args) const { meta_any arguments[sizeof...(Args) + 1u]{std::forward(args)...}; return construct(arguments, sizeof...(Args)); } @@ -1255,7 +1229,7 @@ public: * @param sz Number of parameters to use to invoke the function. * @return A wrapper containing the returned value, if any. */ - meta_any invoke(const id_type id, meta_handle instance, meta_any * const args, const size_type sz) const { + meta_any invoke(const id_type id, meta_handle instance, meta_any *const args, const size_type sz) const { const auto *candidate = lookup<&node_type::func>(args, sz, [id](const auto *curr) { return curr->id == id; }); return candidate ? candidate->invoke(std::move(instance), args) : meta_any{}; } @@ -1272,7 +1246,7 @@ public: * @return A wrapper containing the new instance, if any. */ template - meta_any invoke(const id_type id, meta_handle instance, Args &&... args) const { + meta_any invoke(const id_type id, meta_handle instance, Args &&...args) const { meta_any arguments[sizeof...(Args) + 1u]{std::forward(args)...}; return invoke(id, std::move(instance), arguments, sizeof...(Args)); } @@ -1354,7 +1328,6 @@ private: const node_type *node; }; - /** * @brief Checks if two objects refer to the same type. * @param lhs An object, either valid or not. @@ -1365,44 +1338,37 @@ private: return !(lhs == rhs); } - [[nodiscard]] inline meta_type meta_any::type() const ENTT_NOEXCEPT { return node; } - template -meta_any meta_any::invoke(const id_type id, Args &&... args) const { +meta_any meta_any::invoke(const id_type id, Args &&...args) const { return type().invoke(id, *this, std::forward(args)...); } - template -meta_any meta_any::invoke(const id_type id, Args &&... args) { +meta_any meta_any::invoke(const id_type id, Args &&...args) { return type().invoke(id, *this, std::forward(args)...); } - template bool meta_any::set(const id_type id, Type &&value) { return type().set(id, *this, std::forward(value)); } - [[nodiscard]] inline meta_any meta_any::get(const id_type id) const { return type().get(id, *this); } - [[nodiscard]] inline meta_any meta_any::get(const id_type id) { return type().get(id, *this); } - [[nodiscard]] inline meta_any meta_any::allow_cast(const meta_type &type) const { if(const auto info = type.info(); (node && node->info == info) || internal::visit<&internal::meta_type_node::base>([info](const auto *curr) { return curr->type->info == info; }, node)) { return as_ref(); - } else if(const auto * const conv = internal::visit<&internal::meta_type_node::conv>([info](const auto *curr) { return curr->type->info == info; }, node); conv) { + } else if(const auto *const conv = internal::visit<&internal::meta_type_node::conv>([info](const auto *curr) { return curr->type->info == info; }, node); conv) { return conv->conv(storage.data()); } else if(node && node->conversion_helper && (type.is_arithmetic() || type.is_enum())) { // exploits the fact that arithmetic types and enums are also default constructible @@ -1415,31 +1381,27 @@ bool meta_any::set(const id_type id, Type &&value) { return {}; } - [[nodiscard]] inline meta_type meta_data::type() const ENTT_NOEXCEPT { return node->type; } - [[nodiscard]] inline meta_type meta_func::ret() const ENTT_NOEXCEPT { return node->ret; } - [[nodiscard]] inline meta_type meta_data::arg(const size_type index) const ENTT_NOEXCEPT { return index < arity() ? node->arg(index) : meta_type{}; } - [[nodiscard]] inline meta_type meta_func::arg(const size_type index) const ENTT_NOEXCEPT { return index < arity() ? node->arg(index) : meta_type{}; } - /*! @brief Opaque iterator for sequence containers. */ class meta_sequence_container::meta_iterator { - enum class operation: std::uint8_t { - INCR, DEREF + enum class operation : std::uint8_t { + INCR, + DEREF }; using vtable_type = void(const operation, const any &, void *); @@ -1479,11 +1441,10 @@ public: template meta_iterator(It iter) : vtable{&basic_vtable}, - handle{std::move(iter)} - {} + handle{std::move(iter)} {} /*! @brief Pre-increment operator. @return This iterator. */ - meta_iterator & operator++() ENTT_NOEXCEPT { + meta_iterator &operator++() ENTT_NOEXCEPT { return vtable(operation::INCR, handle, nullptr), *this; } @@ -1542,7 +1503,6 @@ private: any handle{}; }; - /** * @brief Returns the meta value type of a container. * @return The meta value type of the container. @@ -1551,7 +1511,6 @@ private: return value_type_node; } - /** * @brief Returns the size of a container. * @return The size of the container. @@ -1560,7 +1519,6 @@ private: return size_fn(storage); } - /** * @brief Resizes a container to contain a given number of elements. * @param sz The new size of the container. @@ -1570,7 +1528,6 @@ inline bool meta_sequence_container::resize(const size_type sz) { return resize_fn(storage, sz); } - /** * @brief Clears the content of a container. * @return True in case of success, false otherwise. @@ -1579,7 +1536,6 @@ inline bool meta_sequence_container::clear() { return clear_fn(storage); } - /** * @brief Returns an iterator to the first element of a container. * @return An iterator to the first element of the container. @@ -1588,7 +1544,6 @@ inline bool meta_sequence_container::clear() { return begin_fn(storage); } - /** * @brief Returns an iterator that is past the last element of a container. * @return An iterator that is past the last element of the container. @@ -1597,7 +1552,6 @@ inline bool meta_sequence_container::clear() { return end_fn(storage); } - /** * @brief Inserts an element at a specified location of a container. * @param it Iterator before which the element will be inserted. @@ -1608,7 +1562,6 @@ inline meta_sequence_container::iterator meta_sequence_container::insert(iterato return insert_fn(storage, it, value); } - /** * @brief Removes a given element from a container. * @param it Iterator to the element to remove. @@ -1618,7 +1571,6 @@ inline meta_sequence_container::iterator meta_sequence_container::erase(iterator return erase_fn(storage, it); } - /** * @brief Returns a reference to the element at a given location of a container * (no bounds checking is performed). @@ -1629,7 +1581,6 @@ inline meta_sequence_container::iterator meta_sequence_container::erase(iterator return get_fn(storage, pos); } - /** * @brief Returns false if a proxy is invalid, true otherwise. * @return False if the proxy is invalid, true otherwise. @@ -1638,11 +1589,11 @@ inline meta_sequence_container::iterator meta_sequence_container::erase(iterator return static_cast(storage); } - /*! @brief Opaque iterator for associative containers. */ class meta_associative_container::meta_iterator { - enum class operation: std::uint8_t { - INCR, DEREF + enum class operation : std::uint8_t { + INCR, + DEREF }; using vtable_type = void(const operation, const any &, void *); @@ -1689,11 +1640,10 @@ public: template meta_iterator(std::integral_constant, It iter) : vtable{&basic_vtable}, - handle{std::move(iter)} - {} + handle{std::move(iter)} {} /*! @brief Pre-increment operator. @return This iterator. */ - meta_iterator & operator++() ENTT_NOEXCEPT { + meta_iterator &operator++() ENTT_NOEXCEPT { return vtable(operation::INCR, handle, nullptr), *this; } @@ -1744,7 +1694,6 @@ private: any handle{}; }; - /** * @brief Returns true if a container is also key-only, false otherwise. * @return True if the associative container is also key-only, false otherwise. @@ -1753,7 +1702,6 @@ private: return key_only_container; } - /** * @brief Returns the meta key type of a container. * @return The meta key type of the a container. @@ -1762,7 +1710,6 @@ private: return key_type_node; } - /** * @brief Returns the meta mapped type of a container. * @return The meta mapped type of the a container. @@ -1771,37 +1718,31 @@ private: return mapped_type_node; } - /*! @copydoc meta_sequence_container::value_type */ [[nodiscard]] inline meta_type meta_associative_container::value_type() const ENTT_NOEXCEPT { return value_type_node; } - /*! @copydoc meta_sequence_container::size */ [[nodiscard]] inline meta_associative_container::size_type meta_associative_container::size() const ENTT_NOEXCEPT { return size_fn(storage); } - /*! @copydoc meta_sequence_container::clear */ inline bool meta_associative_container::clear() { return clear_fn(storage); } - /*! @copydoc meta_sequence_container::begin */ [[nodiscard]] inline meta_associative_container::iterator meta_associative_container::begin() { return begin_fn(storage); } - /*! @copydoc meta_sequence_container::end */ [[nodiscard]] inline meta_associative_container::iterator meta_associative_container::end() { return end_fn(storage); } - /** * @brief Inserts an element (a key/value pair) into a container. * @param key The key of the element to insert. @@ -1812,7 +1753,6 @@ inline bool meta_associative_container::insert(meta_any key, meta_any value = {} return insert_fn(storage, key, value); } - /** * @brief Removes the specified element from a container. * @param key The key of the element to remove. @@ -1822,7 +1762,6 @@ inline bool meta_associative_container::erase(meta_any key) { return erase_fn(storage, key); } - /** * @brief Returns an iterator to the element with a given key, if any. * @param key The key of the element to search. @@ -1832,7 +1771,6 @@ inline bool meta_associative_container::erase(meta_any key) { return find_fn(storage, key); } - /** * @brief Returns false if a proxy is invalid, true otherwise. * @return False if the proxy is invalid, true otherwise. @@ -1841,8 +1779,6 @@ inline bool meta_associative_container::erase(meta_any key) { return static_cast(storage); } - -} - +} // namespace entt #endif diff --git a/src/entt/meta/node.hpp b/src/entt/meta/node.hpp index 9d5635f6e..73fba6c18 100644 --- a/src/entt/meta/node.hpp +++ b/src/entt/meta/node.hpp @@ -1,7 +1,6 @@ #ifndef ENTT_META_NODE_HPP #define ENTT_META_NODE_HPP - #include #include #include @@ -13,25 +12,20 @@ #include "../core/type_traits.hpp" #include "type_traits.hpp" - namespace entt { - class meta_any; class meta_type; struct meta_handle; - /** * @cond TURN_OFF_DOXYGEN * Internal details not to be documented. */ - namespace internal { - -enum class meta_traits: std::uint32_t { +enum class meta_traits : std::uint32_t { IS_NONE = 0x0000, IS_CONST = 0x0001, IS_STATIC = 0x0002, @@ -46,104 +40,93 @@ enum class meta_traits: std::uint32_t { _entt_enum_as_bitmask }; - struct meta_type_node; - struct meta_prop_node { - meta_prop_node * next; + meta_prop_node *next; const meta_any &id; meta_any &value; }; - struct meta_base_node { - meta_base_node * next; - meta_type_node * const type; - const void *(* const cast)(const void *) ENTT_NOEXCEPT; + meta_base_node *next; + meta_type_node *const type; + const void *(*const cast)(const void *)ENTT_NOEXCEPT; }; - struct meta_conv_node { - meta_conv_node * next; - meta_type_node * const type; - meta_any(* const conv)(const void *); + meta_conv_node *next; + meta_type_node *const type; + meta_any (*const conv)(const void *); }; - struct meta_ctor_node { using size_type = std::size_t; - meta_ctor_node * next; + meta_ctor_node *next; const size_type arity; - meta_type(* const arg)(const size_type) ENTT_NOEXCEPT; - meta_any(* const invoke)(meta_any * const); + meta_type (*const arg)(const size_type) ENTT_NOEXCEPT; + meta_any (*const invoke)(meta_any *const); }; - struct meta_data_node { using size_type = std::size_t; id_type id; - meta_data_node * next; - meta_prop_node * prop; + meta_data_node *next; + meta_prop_node *prop; const size_type arity; const meta_traits traits; - meta_type_node * const type; - meta_type(* const arg)(const size_type) ENTT_NOEXCEPT; - bool(* const set)(meta_handle, meta_any); - meta_any(* const get)(meta_handle); + meta_type_node *const type; + meta_type (*const arg)(const size_type) ENTT_NOEXCEPT; + bool (*const set)(meta_handle, meta_any); + meta_any (*const get)(meta_handle); }; - struct meta_func_node { using size_type = std::size_t; id_type id; - meta_func_node * next; - meta_prop_node * prop; + meta_func_node *next; + meta_prop_node *prop; const size_type arity; const meta_traits traits; - meta_type_node * const ret; - meta_type(* const arg)(const size_type) ENTT_NOEXCEPT; - meta_any(* const invoke)(meta_handle, meta_any * const); + meta_type_node *const ret; + meta_type (*const arg)(const size_type) ENTT_NOEXCEPT; + meta_any (*const invoke)(meta_handle, meta_any *const); }; - struct meta_template_node { using size_type = std::size_t; const size_type arity; - meta_type_node * const type; - meta_type_node *(* const arg)(const size_type) ENTT_NOEXCEPT; + meta_type_node *const type; + meta_type_node *(*const arg)(const size_type)ENTT_NOEXCEPT; }; - struct meta_type_node { using size_type = std::size_t; const type_info info; id_type id; - meta_type_node * next; - meta_prop_node * prop; + meta_type_node *next; + meta_prop_node *prop; const size_type size_of; const meta_traits traits; - meta_any(* const default_constructor)(); - double(* const conversion_helper)(const any &, const any &); + meta_any (*const default_constructor)(); + double (*const conversion_helper)(const any &, const any &); const meta_template_node *const templ; meta_ctor_node *ctor{nullptr}; meta_base_node *base{nullptr}; meta_conv_node *conv{nullptr}; meta_data_node *data{nullptr}; meta_func_node *func{nullptr}; - void(* dtor)(void *){nullptr}; + void (*dtor)(void *){nullptr}; }; - template -meta_type_node * meta_arg_node(type_list, const std::size_t index) ENTT_NOEXCEPT; - +meta_type_node *meta_arg_node(type_list, const std::size_t index) ENTT_NOEXCEPT; template class ENTT_API meta_node { static_assert(std::is_same_v>>, "Invalid type"); - [[nodiscard]] static auto * meta_default_constructor() ENTT_NOEXCEPT { + [[nodiscard]] static auto *meta_default_constructor() ENTT_NOEXCEPT { if constexpr(std::is_default_constructible_v) { return +[]() { return meta_any{std::in_place_type}; }; } else { @@ -151,7 +134,7 @@ class ENTT_API meta_node { } } - [[nodiscard]] static auto * meta_conversion_helper() ENTT_NOEXCEPT { + [[nodiscard]] static auto *meta_conversion_helper() ENTT_NOEXCEPT { if constexpr(std::is_arithmetic_v) { return +[](const any &storage, const any &value) { return value ? static_cast(any_cast(const_cast(storage)) = static_cast(any_cast(value))) : static_cast(any_cast(storage)); @@ -165,7 +148,7 @@ class ENTT_API meta_node { } } - [[nodiscard]] static meta_template_node * meta_template_info() ENTT_NOEXCEPT { + [[nodiscard]] static meta_template_node *meta_template_info() ENTT_NOEXCEPT { if constexpr(is_complete_v>) { static meta_template_node node{ meta_template_traits::args_type::size, @@ -181,7 +164,7 @@ class ENTT_API meta_node { } public: - [[nodiscard]] static meta_type_node * resolve() ENTT_NOEXCEPT { + [[nodiscard]] static meta_type_node *resolve() ENTT_NOEXCEPT { static meta_type_node node{ type_id(), {}, @@ -207,14 +190,12 @@ public: } }; - template -[[nodiscard]] meta_type_node * meta_arg_node(type_list, const std::size_t index) ENTT_NOEXCEPT { +[[nodiscard]] meta_type_node *meta_arg_node(type_list, const std::size_t index) ENTT_NOEXCEPT { meta_type_node *args[sizeof...(Args) + 1u]{nullptr, internal::meta_node>>::resolve()...}; return args[index + 1u]; } - template [[nodiscard]] static std::decay_t().*Member)> visit(const Op &op, const internal::meta_type_node *node) { if(!node) { @@ -236,7 +217,6 @@ template return nullptr; } - [[nodiscard]] inline bool can_cast_or_convert(const internal::meta_type_node *type, const internal::meta_type_node *other) ENTT_NOEXCEPT { if(type->info == other->info) { return true; @@ -257,17 +237,13 @@ template return (type->conversion_helper && other->conversion_helper); } - -} - +} // namespace internal /** * Internal details not to be documented. * @endcond */ - -} - +} // namespace entt #endif diff --git a/src/entt/meta/pointer.hpp b/src/entt/meta/pointer.hpp index 62a2453b1..58d2f103e 100644 --- a/src/entt/meta/pointer.hpp +++ b/src/entt/meta/pointer.hpp @@ -1,24 +1,19 @@ #ifndef ENTT_META_POINTER_HPP #define ENTT_META_POINTER_HPP - #include #include #include "type_traits.hpp" - namespace entt { - /** * @brief Makes plain pointers pointer-like types for the meta system. * @tparam Type Element type. */ template struct is_meta_pointer_like - : std::true_type -{}; - + : std::true_type {}; /** * @brief Partial specialization used to reject pointers to arrays. @@ -26,10 +21,8 @@ struct is_meta_pointer_like * @tparam N Number of elements of the array. */ template -struct is_meta_pointer_like - : std::false_type -{}; - +struct is_meta_pointer_like + : std::false_type {}; /** * @brief Makes `std::shared_ptr`s of any type pointer-like types for the meta @@ -38,9 +31,7 @@ struct is_meta_pointer_like */ template struct is_meta_pointer_like> - : std::true_type -{}; - + : std::true_type {}; /** * @brief Makes `std::unique_ptr`s of any type pointer-like types for the meta @@ -50,11 +41,8 @@ struct is_meta_pointer_like> */ template struct is_meta_pointer_like> - : std::true_type -{}; - - -} + : std::true_type {}; +} // namespace entt #endif diff --git a/src/entt/meta/policy.hpp b/src/entt/meta/policy.hpp index 1b7d9c89b..0c35d9956 100644 --- a/src/entt/meta/policy.hpp +++ b/src/entt/meta/policy.hpp @@ -1,27 +1,20 @@ #ifndef ENTT_META_POLICY_HPP #define ENTT_META_POLICY_HPP - namespace entt { - /*! @brief Empty class type used to request the _as ref_ policy. */ struct as_ref_t {}; - /*! @brief Empty class type used to request the _as cref_ policy. */ struct as_cref_t {}; - /*! @brief Empty class type used to request the _as-is_ policy. */ struct as_is_t {}; - /*! @brief Empty class type used to request the _as void_ policy. */ struct as_void_t {}; - -} - +} // namespace entt #endif diff --git a/src/entt/meta/range.hpp b/src/entt/meta/range.hpp index d68f38ce6..877b1f463 100644 --- a/src/entt/meta/range.hpp +++ b/src/entt/meta/range.hpp @@ -1,14 +1,11 @@ #ifndef ENTT_META_RANGE_HPP #define ENTT_META_RANGE_HPP - #include #include - namespace entt { - /** * @brief Iterable range to use to iterate all types of meta objects. * @tparam Type Type of meta objects returned. @@ -27,10 +24,9 @@ class meta_range { range_iterator() ENTT_NOEXCEPT = default; range_iterator(node_type *head) ENTT_NOEXCEPT - : it{head} - {} + : it{head} {} - range_iterator & operator++() ENTT_NOEXCEPT { + range_iterator &operator++() ENTT_NOEXCEPT { return (it = it->next), *this; } @@ -71,8 +67,7 @@ public: * @param head The underlying node with which to construct the range. */ meta_range(node_type *head) - : node{head} - {} + : node{head} {} /** * @brief Returns an iterator to the beginning. @@ -105,8 +100,6 @@ private: node_type *node{nullptr}; }; - -} - +} // namespace entt #endif diff --git a/src/entt/meta/resolve.hpp b/src/entt/meta/resolve.hpp index 2cb4a47c4..400d9777f 100644 --- a/src/entt/meta/resolve.hpp +++ b/src/entt/meta/resolve.hpp @@ -1,7 +1,6 @@ #ifndef ENTT_META_RESOLVE_HPP #define ENTT_META_RESOLVE_HPP - #include #include "../core/type_info.hpp" #include "ctx.hpp" @@ -9,10 +8,8 @@ #include "node.hpp" #include "range.hpp" - namespace entt { - /** * @brief Returns the meta type associated with a given type. * @tparam Type Type to use to search for a meta type. @@ -23,7 +20,6 @@ template return internal::meta_node>>::resolve(); } - /** * @brief Returns a range to use to visit all meta types. * @return An iterable range to use to visit all meta types. @@ -32,7 +28,6 @@ template return *internal::meta_context::global(); } - /** * @brief Returns the meta type associated with a given identifier, if any. * @param id Unique identifier. @@ -48,7 +43,6 @@ template return {}; } - /** * @brief Returns the meta type associated with a given type info object, if * any. @@ -65,8 +59,6 @@ template return {}; } - -} - +} // namespace entt #endif diff --git a/src/entt/meta/template.hpp b/src/entt/meta/template.hpp index 11f1d25bc..21778117e 100644 --- a/src/entt/meta/template.hpp +++ b/src/entt/meta/template.hpp @@ -1,18 +1,14 @@ #ifndef ENTT_META_TEMPLATE_HPP #define ENTT_META_TEMPLATE_HPP - #include "../core/type_traits.hpp" - namespace entt { - /*! @brief Utility class to disambiguate class templates. */ template typename> struct meta_class_template_tag {}; - /** * @brief General purpose traits class for generating meta template information. * @tparam Clazz Type of class template. @@ -26,8 +22,6 @@ struct meta_template_traits> { using args_type = type_list; }; - -} - +} // namespace entt #endif diff --git a/src/entt/meta/type_traits.hpp b/src/entt/meta/type_traits.hpp index 94991f01f..51b69f692 100644 --- a/src/entt/meta/type_traits.hpp +++ b/src/entt/meta/type_traits.hpp @@ -1,14 +1,11 @@ #ifndef ENTT_META_TYPE_TRAITS_HPP #define ENTT_META_TYPE_TRAITS_HPP - #include #include - namespace entt { - /** * @brief Traits class template to be specialized to enable support for meta * template information. @@ -16,7 +13,6 @@ namespace entt { template struct meta_template_traits; - /** * @brief Traits class template to be specialized to enable support for meta * sequence containers. @@ -24,7 +20,6 @@ struct meta_template_traits; template struct meta_sequence_container_traits; - /** * @brief Traits class template to be specialized to enable support for meta * associative containers. @@ -32,7 +27,6 @@ struct meta_sequence_container_traits; template struct meta_associative_container_traits; - /** * @brief Provides the member constant `value` to true if a given type is a * pointer-like type from the point of view of the meta system, false otherwise. @@ -41,7 +35,6 @@ struct meta_associative_container_traits; template struct is_meta_pointer_like: std::false_type {}; - /** * @brief Partial specialization to ensure that const pointer-like types are * also accepted. @@ -50,7 +43,6 @@ struct is_meta_pointer_like: std::false_type {}; template struct is_meta_pointer_like: is_meta_pointer_like {}; - /** * @brief Helper variable template. * @tparam Type Potentially pointer-like type. @@ -58,8 +50,6 @@ struct is_meta_pointer_like: is_meta_pointer_like {}; template inline constexpr auto is_meta_pointer_like_v = is_meta_pointer_like::value; - -} - +} // namespace entt #endif diff --git a/src/entt/meta/utility.hpp b/src/entt/meta/utility.hpp index a0c088dcd..7e905994d 100644 --- a/src/entt/meta/utility.hpp +++ b/src/entt/meta/utility.hpp @@ -1,7 +1,6 @@ #ifndef ENTT_META_UTILITY_HPP #define ENTT_META_UTILITY_HPP - #include #include #include @@ -12,15 +11,12 @@ #include "node.hpp" #include "policy.hpp" - namespace entt { - /*! @brief Primary template isn't defined on purpose. */ template struct meta_function_descriptor; - /** * @brief Meta function descriptor. * @tparam Type Reflected type to which the meta function is associated. @@ -29,7 +25,7 @@ struct meta_function_descriptor; * @tparam Args Function arguments. */ template -struct meta_function_descriptor { +struct meta_function_descriptor { /*! @brief Meta function return type. */ using return_type = Ret; /*! @brief Meta function arguments. */ @@ -41,7 +37,6 @@ struct meta_function_descriptor { static constexpr auto is_static = !std::is_same_v; }; - /** * @brief Meta function descriptor. * @tparam Type Reflected type to which the meta function is associated. @@ -50,7 +45,7 @@ struct meta_function_descriptor { * @tparam Args Function arguments. */ template -struct meta_function_descriptor { +struct meta_function_descriptor { /*! @brief Meta function return type. */ using return_type = Ret; /*! @brief Meta function arguments. */ @@ -62,7 +57,6 @@ struct meta_function_descriptor { static constexpr auto is_static = !std::is_same_v; }; - /** * @brief Meta function descriptor. * @tparam Type Reflected type to which the meta data is associated. @@ -70,7 +64,7 @@ struct meta_function_descriptor { * @tparam Ret Data member type. */ template -struct meta_function_descriptor { +struct meta_function_descriptor { /*! @brief Meta data return type. */ using return_type = Ret; /*! @brief Meta data arguments. */ @@ -82,7 +76,6 @@ struct meta_function_descriptor { static constexpr auto is_static = false; }; - /** * @brief Meta function descriptor. * @tparam Type Reflected type to which the meta function is associated. @@ -90,7 +83,7 @@ struct meta_function_descriptor { * @tparam Args Function arguments. */ template -struct meta_function_descriptor { +struct meta_function_descriptor { /*! @brief Meta function return type. */ using return_type = Ret; /*! @brief Meta function arguments. */ @@ -102,7 +95,6 @@ struct meta_function_descriptor { static constexpr auto is_static = true; }; - /** * @brief Meta function helper. * @@ -115,16 +107,16 @@ struct meta_function_descriptor { template class meta_function_helper { template - static constexpr meta_function_descriptor get_rid_of_noexcept(Ret(Class:: *)(Args...) const); + static constexpr meta_function_descriptor get_rid_of_noexcept(Ret (Class::*)(Args...) const); template - static constexpr meta_function_descriptor get_rid_of_noexcept(Ret(Class:: *)(Args...)); + static constexpr meta_function_descriptor get_rid_of_noexcept(Ret (Class::*)(Args...)); template - static constexpr meta_function_descriptor get_rid_of_noexcept(Ret Class:: *); + static constexpr meta_function_descriptor get_rid_of_noexcept(Ret Class::*); template - static constexpr meta_function_descriptor get_rid_of_noexcept(Ret(*)(Args...)); + static constexpr meta_function_descriptor get_rid_of_noexcept(Ret (*)(Args...)); template static constexpr meta_function_descriptor get_rid_of_noexcept(Class); @@ -134,7 +126,6 @@ public: using type = decltype(get_rid_of_noexcept(std::declval())); }; - /** * @brief Helper type. * @tparam Type Reflected type to which the meta function is associated. @@ -143,7 +134,6 @@ public: template using meta_function_helper_t = typename meta_function_helper::type; - /** * @brief Wraps a value depending on the given policy. * @tparam Policy Optional policy (no policy set by default). @@ -166,7 +156,6 @@ meta_any meta_dispatch([[maybe_unused]] Type &&value) { } } - /** * @brief Returns the meta type of the i-th element of a list of arguments. * @tparam Type Type list of the actual types of arguments. @@ -177,7 +166,6 @@ template return internal::meta_arg_node(Type{}, index); } - /** * @brief Sets the value of a given variable. * @tparam Type Reflected type to which the variable is associated. @@ -192,14 +180,14 @@ template if constexpr(std::is_function_v>>) { using data_type = type_list_element_t<1u, typename meta_function_helper_t::args_type>; - if(auto * const clazz = instance->try_cast(); clazz && value.allow_cast()) { + if(auto *const clazz = instance->try_cast(); clazz && value.allow_cast()) { Data(*clazz, value.cast()); return true; } } else if constexpr(std::is_member_function_pointer_v) { using data_type = type_list_element_t<0u, typename meta_function_helper_t::args_type>; - if(auto * const clazz = instance->try_cast(); clazz && value.allow_cast()) { + if(auto *const clazz = instance->try_cast(); clazz && value.allow_cast()) { (clazz->*Data)(value.cast()); return true; } @@ -207,7 +195,7 @@ template using data_type = std::remove_reference_t().*Data)>; if constexpr(!std::is_array_v && !std::is_const_v) { - if(auto * const clazz = instance->try_cast(); clazz && value.allow_cast()) { + if(auto *const clazz = instance->try_cast(); clazz && value.allow_cast()) { clazz->*Data = value.cast(); return true; } @@ -227,7 +215,6 @@ template return false; } - /** * @brief Gets the value of a given variable. * @tparam Type Reflected type to which the variable is associated. @@ -239,16 +226,16 @@ template template [[nodiscard]] meta_any meta_getter([[maybe_unused]] meta_handle instance) { if constexpr(std::is_function_v>>) { - auto * const clazz = instance->try_cast, const Type, Type>>(); + auto *const clazz = instance->try_cast, const Type, Type>>(); return clazz ? meta_dispatch(Data(*clazz)) : meta_any{}; } else if constexpr(std::is_member_function_pointer_v) { - auto * const clazz = instance->try_cast, const Type, Type>>(); + auto *const clazz = instance->try_cast, const Type, Type>>(); return clazz ? meta_dispatch((clazz->*Data)()) : meta_any{}; } else if constexpr(std::is_member_object_pointer_v) { if constexpr(!std::is_array_v().*Data)>>>) { - if(auto * clazz = instance->try_cast(); clazz) { + if(auto *clazz = instance->try_cast(); clazz) { return meta_dispatch(clazz->*Data); - } else if(auto * fallback = instance->try_cast(); fallback) { + } else if(auto *fallback = instance->try_cast(); fallback) { return meta_dispatch(fallback->*Data); } } @@ -265,21 +252,18 @@ template } } - /** * @cond TURN_OFF_DOXYGEN * Internal details not to be documented. */ - namespace internal { - template [[nodiscard]] meta_any meta_invoke([[maybe_unused]] meta_handle instance, Candidate &&candidate, meta_any *args, std::index_sequence) { using descriptor = meta_function_helper_t; - const auto invoke = [&candidate](auto &&maybe_clazz, auto &&... other) { + const auto invoke = [&candidate](auto &&maybe_clazz, auto &&...other) { if constexpr(std::is_member_function_pointer_v>) { if constexpr(std::is_void_v) { (std::forward(maybe_clazz).*std::forward(candidate))(std::forward(other)...); @@ -298,42 +282,38 @@ template, const Type &, type_list_element_t...>) { - if(const auto * const clazz = instance->try_cast(); clazz && ((args+Index)->allow_cast>() && ...)) { - return invoke(*clazz, (args+Index)->cast>()...); + if(const auto *const clazz = instance->try_cast(); clazz && ((args + Index)->allow_cast>() && ...)) { + return invoke(*clazz, (args + Index)->cast>()...); } } else if constexpr(std::is_invocable_v, Type &, type_list_element_t...>) { - if(auto * const clazz = instance->try_cast(); clazz && ((args+Index)->allow_cast>() && ...)) { - return invoke(*clazz, (args+Index)->cast>()...); + if(auto *const clazz = instance->try_cast(); clazz && ((args + Index)->allow_cast>() && ...)) { + return invoke(*clazz, (args + Index)->cast>()...); } } else { - if(((args+Index)->allow_cast>() && ...)) { - return invoke((args+Index)->cast>()...); + if(((args + Index)->allow_cast>() && ...)) { + return invoke((args + Index)->cast>()...); } } return meta_any{}; } - template -[[nodiscard]] meta_any meta_construct(meta_any * const args, std::index_sequence) { - if(((args+Index)->allow_cast() && ...)) { - return Type{(args+Index)->cast()...}; +[[nodiscard]] meta_any meta_construct(meta_any *const args, std::index_sequence) { + if(((args + Index)->allow_cast() && ...)) { + return Type{(args + Index)->cast()...}; } return meta_any{}; } - -} - +} // namespace internal /** * Internal details not to be documented. * @endcond */ - /** * @brief Invokes a callable object given a list of erased parameters, if * possible. @@ -346,7 +326,7 @@ template * @return A meta any containing the returned value, if any. */ template -[[nodiscard]] meta_any meta_invoke([[maybe_unused]] meta_handle instance, Candidate &&candidate, [[maybe_unused]] meta_any * const args) { +[[nodiscard]] meta_any meta_invoke([[maybe_unused]] meta_handle instance, Candidate &&candidate, [[maybe_unused]] meta_any *const args) { if constexpr(std::is_invocable_v>) { if constexpr(std::is_void_v(candidate)())>) { std::forward(candidate)(); @@ -359,7 +339,6 @@ template } } - /** * @brief Invokes a function given a list of erased parameters, if possible. * @tparam Type Reflected type to which the function is associated. @@ -370,11 +349,10 @@ template * @return A meta any containing the returned value, if any. */ template -[[nodiscard]] meta_any meta_invoke(meta_handle instance, meta_any * const args) { +[[nodiscard]] meta_any meta_invoke(meta_handle instance, meta_any *const args) { return meta_invoke(std::move(instance), Candidate, args); } - /** * @brief Constructs an instance given a list of erased parameters, if possible. * @tparam Type Actual type of the instance to construct. @@ -383,11 +361,10 @@ template * @return A meta any containing the new instance, if any. */ template -[[nodiscard]] meta_any meta_construct(meta_any * const args) { +[[nodiscard]] meta_any meta_construct(meta_any *const args) { return internal::meta_construct(args, std::index_sequence_for{}); } - /** * @brief Constructs an instance given a list of erased parameters, if possible. * @tparam Type Reflected type to which the callable object is associated. @@ -398,11 +375,10 @@ template * @return A meta any containing the returned value, if any. */ template -[[nodiscard]] meta_any meta_construct(Candidate &&candidate, meta_any * const args) { +[[nodiscard]] meta_any meta_construct(Candidate &&candidate, meta_any *const args) { return meta_invoke({}, std::forward(candidate), args); } - /** * @brief Constructs an instance given a list of erased parameters, if possible. * @tparam Type Reflected type to which the function is associated. @@ -412,12 +388,10 @@ template * @return A meta any containing the returned value, if any. */ template -[[nodiscard]] meta_any meta_construct(meta_any * const args) { +[[nodiscard]] meta_any meta_construct(meta_any *const args) { return meta_invoke({}, Candidate, args); } - -} - +} // namespace entt #endif diff --git a/src/entt/platform/android-ndk-r17.hpp b/src/entt/platform/android-ndk-r17.hpp index 8527f3e21..569612353 100644 --- a/src/entt/platform/android-ndk-r17.hpp +++ b/src/entt/platform/android-ndk-r17.hpp @@ -1,37 +1,29 @@ #ifndef ENTT_PLATFORM_ANDROID_NDK_R17_HPP #define ENTT_PLATFORM_ANDROID_NDK_R17_HPP - /** * @cond TURN_OFF_DOXYGEN * Internal details not to be documented. */ - #ifdef __ANDROID__ -#include -#if __NDK_MAJOR__ == 17 - - -#include -#include -#include +# include +# if __NDK_MAJOR__ == 17 +# include +# include +# include namespace std { - namespace internal { - template constexpr auto is_invocable(int) -> decltype(std::invoke(std::declval(), std::declval()...), std::true_type{}); - template constexpr std::false_type is_invocable(...); - template constexpr auto is_invocable_r(int) -> std::enable_if_t(), std::declval()...)), Ret>, std::true_type>; @@ -40,47 +32,36 @@ constexpr auto is_invocable_r(int) template constexpr std::false_type is_invocable_r(...); - -} - +} // namespace internal template struct is_invocable: decltype(internal::is_invocable(0)) {}; - template inline constexpr bool is_invocable_v = std::is_invocable::value; - template struct is_invocable_r: decltype(internal::is_invocable_r(0)) {}; - template inline constexpr bool is_invocable_r_v = std::is_invocable_r::value; - -template +template struct invoke_result { using type = decltype(std::invoke(std::declval(), std::declval()...)); }; - template using invoke_result_t = typename std::invoke_result::type; +} // namespace std -} - - +# endif #endif -#endif - /** * Internal details not to be documented. * @endcond */ - #endif diff --git a/src/entt/poly/fwd.hpp b/src/entt/poly/fwd.hpp index 32023e27d..55f859266 100644 --- a/src/entt/poly/fwd.hpp +++ b/src/entt/poly/fwd.hpp @@ -1,17 +1,13 @@ #ifndef ENTT_POLY_FWD_HPP #define ENTT_POLY_FWD_HPP - #include - namespace entt { - template)> class basic_poly; - /** * @brief Alias declaration for the most common use case. * @tparam Concept Concept descriptor. @@ -19,8 +15,6 @@ class basic_poly; template using poly = basic_poly; - -} - +} // namespace entt #endif diff --git a/src/entt/poly/poly.hpp b/src/entt/poly/poly.hpp index 1fcb400e8..5848801b4 100644 --- a/src/entt/poly/poly.hpp +++ b/src/entt/poly/poly.hpp @@ -1,7 +1,6 @@ #ifndef ENTT_POLY_POLY_HPP #define ENTT_POLY_POLY_HPP - #include #include #include @@ -13,17 +12,15 @@ #include "../core/type_traits.hpp" #include "fwd.hpp" - namespace entt { - /*! @brief Inspector class used to infer the type of the virtual table. */ struct poly_inspector { /** * @brief Generic conversion operator (definition only). * @tparam Type Type to which conversion is requested. */ - template + template operator Type &&() const; /** @@ -34,14 +31,13 @@ struct poly_inspector { * @return A poly inspector convertible to any type. */ template - poly_inspector invoke(Args &&... args) const; + poly_inspector invoke(Args &&...args) const; /*! @copydoc invoke */ template - poly_inspector invoke(Args &&... args); + poly_inspector invoke(Args &&...args); }; - /** * @brief Static virtual table factory. * @tparam Concept Concept descriptor. @@ -53,35 +49,35 @@ class poly_vtable { using inspector = typename Concept::template type; template - static auto vtable_entry(Ret(*)(inspector &, Args...)) -> Ret(*)(basic_any &, Args...); + static auto vtable_entry(Ret (*)(inspector &, Args...)) -> Ret (*)(basic_any &, Args...); template - static auto vtable_entry(Ret(*)(const inspector &, Args...)) -> Ret(*)(const basic_any &, Args...); + static auto vtable_entry(Ret (*)(const inspector &, Args...)) -> Ret (*)(const basic_any &, Args...); template - static auto vtable_entry(Ret(*)(Args...)) -> Ret(*)(const basic_any &, Args...); + static auto vtable_entry(Ret (*)(Args...)) -> Ret (*)(const basic_any &, Args...); template - static auto vtable_entry(Ret(inspector:: *)(Args...)) -> Ret(*)(basic_any &, Args...); + static auto vtable_entry(Ret (inspector::*)(Args...)) -> Ret (*)(basic_any &, Args...); template - static auto vtable_entry(Ret(inspector:: *)(Args...) const) -> Ret(*)(const basic_any &, Args...); + static auto vtable_entry(Ret (inspector::*)(Args...) const) -> Ret (*)(const basic_any &, Args...); template static auto make_vtable(value_list) - -> decltype(std::make_tuple(vtable_entry(Candidate)...)); + -> decltype(std::make_tuple(vtable_entry(Candidate)...)); template - [[nodiscard]] static constexpr auto make_vtable(type_list) { + [[nodiscard]] static constexpr auto make_vtable(type_list) { if constexpr(sizeof...(Func) == 0u) { return decltype(make_vtable(typename Concept::template impl{})){}; } else if constexpr((std::is_function_v && ...)) { - return decltype(std::make_tuple(vtable_entry(std::declval())...)){}; + return decltype(std::make_tuple(vtable_entry(std::declval())...)){}; } } template - static void fill_vtable_entry(Ret(* &entry)(Any &, Args...)) { + static void fill_vtable_entry(Ret (*&entry)(Any &, Args...)) { if constexpr(std::is_invocable_r_v) { entry = +[](Any &, Args... args) -> Ret { return std::invoke(Candidate, std::forward(args)...); @@ -125,7 +121,6 @@ public: } }; - /** * @brief Poly base class used to inject functionalities into concepts. * @tparam Poly The outermost poly class. @@ -141,7 +136,7 @@ struct poly_base { * @return The return value of the invoked function, if any. */ template - [[nodiscard]] decltype(auto) invoke(const poly_base &self, Args &&... args) const { + [[nodiscard]] decltype(auto) invoke(const poly_base &self, Args &&...args) const { const auto &poly = static_cast(self); if constexpr(std::is_function_v>) { @@ -153,7 +148,7 @@ struct poly_base { /*! @copydoc invoke */ template - [[nodiscard]] decltype(auto) invoke(poly_base &self, Args &&... args) { + [[nodiscard]] decltype(auto) invoke(poly_base &self, Args &&...args) { auto &poly = static_cast(self); if constexpr(std::is_function_v>) { @@ -164,7 +159,6 @@ struct poly_base { } }; - /** * @brief Shortcut for calling `poly_base::invoke`. * @tparam Member Index of the function to invoke. @@ -175,11 +169,10 @@ struct poly_base { * @return The return value of the invoked function, if any. */ template -decltype(auto) poly_call(Poly &&self, Args &&... args) { +decltype(auto) poly_call(Poly &&self, Args &&...args) { return std::forward(self).template invoke(self, std::forward(args)...); } - /** * @brief Static polymorphism made simple and within everyone's reach. * @@ -209,8 +202,7 @@ public: /*! @brief Default constructor. */ basic_poly() ENTT_NOEXCEPT : storage{}, - vtable{} - {} + vtable{} {} /** * @brief Constructs a poly by directly initializing the new object. @@ -219,10 +211,9 @@ public: * @param args Parameters to use to construct the instance. */ template - explicit basic_poly(std::in_place_type_t, Args &&... args) + explicit basic_poly(std::in_place_type_t, Args &&...args) : storage{std::in_place_type, std::forward(args)...}, - vtable{poly_vtable::template instance>>()} - {} + vtable{poly_vtable::template instance>>()} {} /** * @brief Constructs a poly from a given value. @@ -231,8 +222,7 @@ public: */ template>, basic_poly>>> basic_poly(Type &&value) ENTT_NOEXCEPT - : basic_poly{std::in_place_type>>, std::forward(value)} - {} + : basic_poly{std::in_place_type>>, std::forward(value)} {} /** * @brief Returns the object type if any, `type_id()` otherwise. @@ -246,12 +236,12 @@ public: * @brief Returns an opaque pointer to the contained instance. * @return An opaque pointer the contained instance, if any. */ - [[nodiscard]] const void * data() const ENTT_NOEXCEPT { + [[nodiscard]] const void *data() const ENTT_NOEXCEPT { return storage.data(); } /*! @copydoc data */ - [[nodiscard]] void * data() ENTT_NOEXCEPT { + [[nodiscard]] void *data() ENTT_NOEXCEPT { return storage.data(); } @@ -262,7 +252,7 @@ public: * @param args Parameters to use to construct the instance. */ template - void emplace(Args &&... args) { + void emplace(Args &&...args) { storage.template emplace(std::forward(args)...); vtable = poly_vtable::template instance>>(); } @@ -285,12 +275,12 @@ public: * @brief Returns a pointer to the underlying concept. * @return A pointer to the underlying concept. */ - [[nodiscard]] concept_type * operator->() ENTT_NOEXCEPT { + [[nodiscard]] concept_type *operator->() ENTT_NOEXCEPT { return this; } /*! @copydoc operator-> */ - [[nodiscard]] const concept_type * operator->() const ENTT_NOEXCEPT { + [[nodiscard]] const concept_type *operator->() const ENTT_NOEXCEPT { return this; } @@ -318,8 +308,6 @@ private: vtable_type vtable; }; - -} - +} // namespace entt #endif diff --git a/src/entt/process/process.hpp b/src/entt/process/process.hpp index da69bcfbb..d8fe7dc68 100644 --- a/src/entt/process/process.hpp +++ b/src/entt/process/process.hpp @@ -1,15 +1,12 @@ #ifndef ENTT_PROCESS_PROCESS_HPP #define ENTT_PROCESS_PROCESS_HPP - -#include #include +#include #include "../config/config.h" - namespace entt { - /** * @brief Base class for processes. * @@ -71,7 +68,7 @@ namespace entt { */ template class process { - enum class state: unsigned int { + enum class state : unsigned int { UNINITIALIZED = 0, RUNNING, PAUSED, @@ -84,31 +81,31 @@ class process { template auto next(std::integral_constant) - -> decltype(std::declval().init(), void()) { + -> decltype(std::declval().init(), void()) { static_cast(this)->init(); } template auto next(std::integral_constant, Delta delta, void *data) - -> decltype(std::declval().update(delta, data), void()) { + -> decltype(std::declval().update(delta, data), void()) { static_cast(this)->update(delta, data); } template auto next(std::integral_constant) - -> decltype(std::declval().succeeded(), void()) { + -> decltype(std::declval().succeeded(), void()) { static_cast(this)->succeeded(); } template auto next(std::integral_constant) - -> decltype(std::declval().failed(), void()) { + -> decltype(std::declval().failed(), void()) { static_cast(this)->failed(); } template auto next(std::integral_constant) - -> decltype(std::declval().aborted(), void()) { + -> decltype(std::declval().aborted(), void()) { static_cast(this)->aborted(); } @@ -158,8 +155,8 @@ protected: * paused. */ void unpause() ENTT_NOEXCEPT { - if(current == state::PAUSED) { - current = state::RUNNING; + if(current == state::PAUSED) { + current = state::RUNNING; } } @@ -228,7 +225,7 @@ public: * @param data Optional data. */ void tick(const Delta delta, void *data = nullptr) { - switch (current) { + switch(current) { case state::UNINITIALIZED: next(std::integral_constant{}); current = state::RUNNING; @@ -265,7 +262,6 @@ private: state current{state::UNINITIALIZED}; }; - /** * @brief Adaptor for lambdas and functors to turn them into processes. * @@ -313,9 +309,8 @@ struct process_adaptor: process, Delta>, private Fu * @param args Parameters to use to initialize the actual process. */ template - process_adaptor(Args &&... args) - : Func{std::forward(args)...} - {} + process_adaptor(Args &&...args) + : Func{std::forward(args)...} {} /** * @brief Updates a process and its internal state if required. @@ -327,13 +322,10 @@ struct process_adaptor: process, Delta>, private Fu delta, data, [this]() { this->succeed(); }, - [this]() { this->fail(); } - ); + [this]() { this->fail(); }); } }; - -} - +} // namespace entt #endif diff --git a/src/entt/process/scheduler.hpp b/src/entt/process/scheduler.hpp index fd37def70..4856c030f 100644 --- a/src/entt/process/scheduler.hpp +++ b/src/entt/process/scheduler.hpp @@ -1,19 +1,16 @@ #ifndef ENTT_PROCESS_SCHEDULER_HPP #define ENTT_PROCESS_SCHEDULER_HPP - -#include -#include -#include #include +#include #include +#include +#include #include "../config/config.h" #include "process.hpp" - namespace entt { - /** * @brief Cooperative scheduler for processes. * @@ -43,7 +40,7 @@ namespace entt { template class scheduler { struct process_handler { - using instance_type = std::unique_ptr; + using instance_type = std::unique_ptr; using update_fn_type = bool(process_handler &, Delta, void *); using abort_fn_type = void(process_handler &, bool); using next_type = std::unique_ptr; @@ -56,11 +53,10 @@ class scheduler { struct continuation { continuation(process_handler *ref) - : handler{ref} - {} + : handler{ref} {} template - continuation then(Args &&... args) { + continuation then(Args &&...args) { static_assert(std::is_base_of_v, Proc>, "Invalid process type"); auto proc = typename process_handler::instance_type{new Proc{std::forward(args)...}, &scheduler::deleter}; handler->next.reset(new process_handler{std::move(proc), &scheduler::update, &scheduler::abort, nullptr}); @@ -118,7 +114,7 @@ public: scheduler(scheduler &&) = default; /*! @brief Default move assignment operator. @return This scheduler. */ - scheduler & operator=(scheduler &&) = default; + scheduler &operator=(scheduler &&) = default; /** * @brief Number of processes currently scheduled. @@ -172,7 +168,7 @@ public: * @return An opaque object to use to concatenate processes. */ template - auto attach(Args &&... args) { + auto attach(Args &&...args) { static_assert(std::is_base_of_v, Proc>, "Invalid process type"); auto proc = typename process_handler::instance_type{new Proc{std::forward(args)...}, &scheduler::deleter}; process_handler handler{std::move(proc), &scheduler::update, &scheduler::abort, nullptr}; @@ -253,7 +249,7 @@ public: auto sz = handlers.size(); for(auto pos = handlers.size(); pos; --pos) { - auto &handler = handlers[pos-1]; + auto &handler = handlers[pos - 1]; if(const auto dead = handler.update(handler, delta, data); dead) { std::swap(handler, handlers[--sz]); @@ -289,8 +285,6 @@ private: std::vector handlers{}; }; - -} - +} // namespace entt #endif diff --git a/src/entt/resource/cache.hpp b/src/entt/resource/cache.hpp index 031373cc6..62daf3eed 100644 --- a/src/entt/resource/cache.hpp +++ b/src/entt/resource/cache.hpp @@ -1,20 +1,17 @@ #ifndef ENTT_RESOURCE_CACHE_HPP #define ENTT_RESOURCE_CACHE_HPP - #include #include #include #include "../config/config.h" #include "../core/fwd.hpp" +#include "fwd.hpp" #include "handle.hpp" #include "loader.hpp" -#include "fwd.hpp" - namespace entt { - /** * @brief Simple cache for resources of a given type. * @@ -39,7 +36,7 @@ struct resource_cache { resource_cache(resource_cache &&) = default; /*! @brief Default move assignment operator. @return This cache. */ - resource_cache & operator=(resource_cache &&) = default; + resource_cache &operator=(resource_cache &&) = default; /** * @brief Number of resources managed by a cache. @@ -90,7 +87,7 @@ struct resource_cache { * @return A handle for the given resource. */ template - resource_handle load(const id_type id, Args &&... args) { + resource_handle load(const id_type id, Args &&...args) { if(auto it = resources.find(id); it == resources.cend()) { if(auto handle = temp(std::forward(args)...); handle) { return (resources[id] = std::move(handle)); @@ -126,7 +123,7 @@ struct resource_cache { * @return A handle for the given resource. */ template - resource_handle reload(const id_type id, Args &&... args) { + resource_handle reload(const id_type id, Args &&...args) { return (discard(id), load(id, std::forward(args)...)); } @@ -143,7 +140,7 @@ struct resource_cache { * @return A handle for the given resource. */ template - [[nodiscard]] resource_handle temp(Args &&... args) const { + [[nodiscard]] resource_handle temp(Args &&...args) const { return Loader{}.get(std::forward(args)...); } @@ -208,7 +205,7 @@ struct resource_cache { * @tparam Func Type of the function object to invoke. * @param func A valid function object. */ - template + template void each(Func func) const { auto begin = resources.begin(); auto end = resources.end(); @@ -230,8 +227,6 @@ private: std::unordered_map> resources; }; - -} - +} // namespace entt #endif diff --git a/src/entt/resource/fwd.hpp b/src/entt/resource/fwd.hpp index 8a2c9e901..4f279988a 100644 --- a/src/entt/resource/fwd.hpp +++ b/src/entt/resource/fwd.hpp @@ -1,23 +1,17 @@ #ifndef ENTT_RESOURCE_FWD_HPP #define ENTT_RESOURCE_FWD_HPP - namespace entt { - template struct resource_cache; - template class resource_handle; - template class resource_loader; - -} - +} // namespace entt #endif diff --git a/src/entt/resource/handle.hpp b/src/entt/resource/handle.hpp index f9137cbb9..24d5b73cd 100644 --- a/src/entt/resource/handle.hpp +++ b/src/entt/resource/handle.hpp @@ -1,17 +1,14 @@ #ifndef ENTT_RESOURCE_HANDLE_HPP #define ENTT_RESOURCE_HANDLE_HPP - #include #include #include #include "../config/config.h" #include "fwd.hpp" - namespace entt { - /** * @brief Shared resource handle. * @@ -42,8 +39,7 @@ public: * @param res A pointer to a properly initialized resource. */ resource_handle(std::shared_ptr res) ENTT_NOEXCEPT - : resource{std::move(res)} - {} + : resource{std::move(res)} {} /** * @brief Copy constructor. @@ -64,8 +60,7 @@ public: */ template && std::is_base_of_v>> resource_handle(const resource_handle &other) ENTT_NOEXCEPT - : resource{other.resource} - {} + : resource{other.resource} {} /** * @brief Move constructs a handle which takes ownership of the resource. @@ -74,22 +69,21 @@ public: */ template && std::is_base_of_v>> resource_handle(resource_handle &&other) ENTT_NOEXCEPT - : resource{std::move(other.resource)} - {} + : resource{std::move(other.resource)} {} /** * @brief Copy assignment operator. * @param other The instance to copy from. * @return This resource handle. */ - resource_handle & operator=(const resource_handle &other) ENTT_NOEXCEPT = default; + resource_handle &operator=(const resource_handle &other) ENTT_NOEXCEPT = default; /** * @brief Move assignment operator. * @param other The instance to move from. * @return This resource handle. */ - resource_handle & operator=(resource_handle &&other) ENTT_NOEXCEPT = default; + resource_handle &operator=(resource_handle &&other) ENTT_NOEXCEPT = default; /** * @brief Copy assignment operator from foreign handle. @@ -125,33 +119,33 @@ public: * * @return A reference to the managed resource. */ - [[nodiscard]] const Resource & get() const ENTT_NOEXCEPT { + [[nodiscard]] const Resource &get() const ENTT_NOEXCEPT { ENTT_ASSERT(static_cast(resource), "Invalid resource"); return *resource; } /*! @copydoc get */ - [[nodiscard]] Resource & get() ENTT_NOEXCEPT { + [[nodiscard]] Resource &get() ENTT_NOEXCEPT { return const_cast(std::as_const(*this).get()); } /*! @copydoc get */ - [[nodiscard]] operator const Resource & () const ENTT_NOEXCEPT { + [[nodiscard]] operator const Resource &() const ENTT_NOEXCEPT { return get(); } /*! @copydoc get */ - [[nodiscard]] operator Resource & () ENTT_NOEXCEPT { + [[nodiscard]] operator Resource &() ENTT_NOEXCEPT { return get(); } /*! @copydoc get */ - [[nodiscard]] const Resource & operator *() const ENTT_NOEXCEPT { + [[nodiscard]] const Resource &operator*() const ENTT_NOEXCEPT { return get(); } /*! @copydoc get */ - [[nodiscard]] Resource & operator *() ENTT_NOEXCEPT { + [[nodiscard]] Resource &operator*() ENTT_NOEXCEPT { return get(); } @@ -164,12 +158,12 @@ public: * @return A pointer to the managed resource or `nullptr` if the handle * contains no resource at all. */ - [[nodiscard]] const Resource * operator->() const ENTT_NOEXCEPT { + [[nodiscard]] const Resource *operator->() const ENTT_NOEXCEPT { return resource.get(); } /*! @copydoc operator-> */ - [[nodiscard]] Resource * operator->() ENTT_NOEXCEPT { + [[nodiscard]] Resource *operator->() ENTT_NOEXCEPT { return const_cast(std::as_const(*this).operator->()); } @@ -193,8 +187,6 @@ private: std::shared_ptr resource; }; - -} - +} // namespace entt #endif diff --git a/src/entt/resource/loader.hpp b/src/entt/resource/loader.hpp index fa39d55bc..06ae9ef38 100644 --- a/src/entt/resource/loader.hpp +++ b/src/entt/resource/loader.hpp @@ -1,14 +1,11 @@ #ifndef ENTT_RESOURCE_LOADER_HPP #define ENTT_RESOURCE_LOADER_HPP - #include "fwd.hpp" #include "handle.hpp" - namespace entt { - /** * @brief Base class for resource loaders. * @@ -54,13 +51,11 @@ class resource_loader { * @return The resource just loaded or an empty pointer in case of errors. */ template - [[nodiscard]] resource_handle get(Args &&... args) const { + [[nodiscard]] resource_handle get(Args &&...args) const { return static_cast(this)->load(std::forward(args)...); } }; - -} - +} // namespace entt #endif diff --git a/src/entt/signal/delegate.hpp b/src/entt/signal/delegate.hpp index e23fd2b4e..388e0cbf2 100644 --- a/src/entt/signal/delegate.hpp +++ b/src/entt/signal/delegate.hpp @@ -1,77 +1,61 @@ #ifndef ENTT_SIGNAL_DELEGATE_HPP #define ENTT_SIGNAL_DELEGATE_HPP - -#include #include -#include #include +#include #include -#include "../core/type_traits.hpp" +#include #include "../config/config.h" - +#include "../core/type_traits.hpp" namespace entt { - /** * @cond TURN_OFF_DOXYGEN * Internal details not to be documented. */ - namespace internal { - template -auto function_pointer(Ret(*)(Args...)) -> Ret(*)(Args...); - +auto function_pointer(Ret (*)(Args...)) -> Ret (*)(Args...); template -auto function_pointer(Ret(*)(Type, Args...), Other &&) -> Ret(*)(Args...); - +auto function_pointer(Ret (*)(Type, Args...), Other &&) -> Ret (*)(Args...); template -auto function_pointer(Ret(Class:: *)(Args...), Other &&...) -> Ret(*)(Args...); - +auto function_pointer(Ret (Class::*)(Args...), Other &&...) -> Ret (*)(Args...); template -auto function_pointer(Ret(Class:: *)(Args...) const, Other &&...) -> Ret(*)(Args...); - +auto function_pointer(Ret (Class::*)(Args...) const, Other &&...) -> Ret (*)(Args...); template -auto function_pointer(Type Class:: *, Other &&...) -> Type(*)(); - +auto function_pointer(Type Class::*, Other &&...) -> Type (*)(); template using function_pointer_t = decltype(internal::function_pointer(std::declval()...)); - template -[[nodiscard]] constexpr auto index_sequence_for(Ret(*)(Args...)) { +[[nodiscard]] constexpr auto index_sequence_for(Ret (*)(Args...)) { return std::index_sequence_for{}; } - -} - +} // namespace internal /** * Internal details not to be documented. * @endcond */ - /*! @brief Used to wrap a function or a member of a specified type. */ template struct connect_arg_t {}; - /*! @brief Constant of type connect_arg_t used to disambiguate calls. */ template inline constexpr connect_arg_t connect_arg{}; - /** * @brief Basic delegate implementation. * @@ -81,7 +65,6 @@ inline constexpr connect_arg_t connect_arg{}; template class delegate; - /** * @brief Utility class to use to send around functions and members. * @@ -132,8 +115,8 @@ public: /*! @brief Default constructor. */ delegate() ENTT_NOEXCEPT - : fn{nullptr}, data{nullptr} - {} + : fn{nullptr}, + data{nullptr} {} /** * @brief Constructs a delegate and connects a free function or an unbound @@ -271,7 +254,7 @@ public: * @brief Returns the instance or the payload linked to a delegate, if any. * @return An opaque pointer to the underlying data. */ - [[nodiscard]] const void * instance() const ENTT_NOEXCEPT { + [[nodiscard]] const void *instance() const ENTT_NOEXCEPT { return data; } @@ -315,7 +298,6 @@ private: const void *data; }; - /** * @brief Compares the contents of two delegates. * @tparam Ret Return type of a function type. @@ -329,7 +311,6 @@ template return !(lhs == rhs); } - /** * @brief Deduction guide. * @tparam Candidate Function or member to connect to the delegate. @@ -337,7 +318,6 @@ template template delegate(connect_arg_t) -> delegate>>; - /** * @brief Deduction guide. * @tparam Candidate Function or member to connect to the delegate. @@ -346,17 +326,14 @@ delegate(connect_arg_t) -> delegate delegate(connect_arg_t, Type &&) -> delegate>>; - /** * @brief Deduction guide. * @tparam Ret Return type of a function type. * @tparam Args Types of arguments of a function type. */ template -delegate(Ret(*)(const void *, Args...), const void * = nullptr) -> delegate; - - -} +delegate(Ret (*)(const void *, Args...), const void * = nullptr) -> delegate; +} // namespace entt #endif diff --git a/src/entt/signal/dispatcher.hpp b/src/entt/signal/dispatcher.hpp index 915ff7709..dffc13706 100644 --- a/src/entt/signal/dispatcher.hpp +++ b/src/entt/signal/dispatcher.hpp @@ -1,7 +1,6 @@ #ifndef ENTT_SIGNAL_DISPATCHER_HPP #define ENTT_SIGNAL_DISPATCHER_HPP - #include #include #include @@ -12,10 +11,8 @@ #include "../core/type_info.hpp" #include "sigh.hpp" - namespace entt { - /** * @brief Basic dispatcher implementation. * @@ -50,7 +47,7 @@ class dispatcher { signal.publish(events[pos]); } - events.erase(events.cbegin(), events.cbegin()+length); + events.erase(events.cbegin(), events.cbegin() + length); } void disconnect(void *instance) override { @@ -66,13 +63,13 @@ class dispatcher { } template - void trigger(Args &&... args) { + void trigger(Args &&...args) { Event instance{std::forward(args)...}; signal.publish(instance); } template - void enqueue(Args &&... args) { + void enqueue(Args &&...args) { if constexpr(std::is_aggregate_v) { events.push_back(Event{std::forward(args)...}); } else { @@ -86,11 +83,11 @@ class dispatcher { }; template - [[nodiscard]] pool_handler & assure() { + [[nodiscard]] pool_handler &assure() { const auto index = type_index::value(); if(!(index < pools.size())) { - pools.resize(std::size_t(index)+1u); + pools.resize(std::size_t(index) + 1u); } if(!pools[index]) { @@ -108,7 +105,7 @@ public: dispatcher(dispatcher &&) = default; /*! @brief Default move assignment operator. @return This dispatcher. */ - dispatcher & operator=(dispatcher &&) = default; + dispatcher &operator=(dispatcher &&) = default; /** * @brief Returns a sink object for the given event. @@ -143,7 +140,7 @@ public: * @param args Arguments to use to construct the event. */ template - void trigger(Args &&... args) { + void trigger(Args &&...args) { assure().trigger(std::forward(args)...); } @@ -172,7 +169,7 @@ public: * @param args Arguments to use to construct the event. */ template - void enqueue(Args &&... args) { + void enqueue(Args &&...args) { assure().enqueue(std::forward(args)...); } @@ -260,7 +257,7 @@ public: */ void update() const { for(auto pos = pools.size(); pos; --pos) { - if(auto &&cpool = pools[pos-1]; cpool) { + if(auto &&cpool = pools[pos - 1]; cpool) { cpool->publish(); } } @@ -270,8 +267,6 @@ private: std::vector> pools; }; - -} - +} // namespace entt #endif diff --git a/src/entt/signal/emitter.hpp b/src/entt/signal/emitter.hpp index 99469f6f9..bbb0a526a 100644 --- a/src/entt/signal/emitter.hpp +++ b/src/entt/signal/emitter.hpp @@ -1,7 +1,6 @@ #ifndef ENTT_SIGNAL_EMITTER_HPP #define ENTT_SIGNAL_EMITTER_HPP - #include #include #include @@ -14,10 +13,8 @@ #include "../core/fwd.hpp" #include "../core/type_info.hpp" - namespace entt { - /** * @brief General purpose event emitter. * @@ -60,7 +57,7 @@ class emitter { auto pred = [](auto &&element) { return element.first; }; return std::all_of(once_list.cbegin(), once_list.cend(), pred) - && std::all_of(on_list.cbegin(), on_list.cend(), pred); + && std::all_of(on_list.cbegin(), on_list.cend(), pred); } void clear() ENTT_NOEXCEPT override { @@ -122,11 +119,11 @@ class emitter { }; template - [[nodiscard]] pool_handler * assure() { + [[nodiscard]] pool_handler *assure() { const auto index = type_index::value(); if(!(index < pools.size())) { - pools.resize(std::size_t(index)+1u); + pools.resize(std::size_t(index) + 1u); } if(!pools[index]) { @@ -137,7 +134,7 @@ class emitter { } template - [[nodiscard]] const pool_handler * assure() const { + [[nodiscard]] const pool_handler *assure() const { const auto index = type_index::value(); return (!(index < pools.size()) || !pools[index]) ? nullptr : static_cast *>(pools[index].get()); } @@ -169,8 +166,7 @@ public: * @param conn A connection object to wrap. */ connection(typename pool_handler::connection_type conn) - : pool_handler::connection_type{std::move(conn)} - {} + : pool_handler::connection_type{std::move(conn)} {} }; /*! @brief Default constructor. */ @@ -185,7 +181,7 @@ public: emitter(emitter &&) = default; /*! @brief Default move assignment operator. @return This emitter. */ - emitter & operator=(emitter &&) = default; + emitter &operator=(emitter &&) = default; /** * @brief Emits the given event. @@ -199,7 +195,7 @@ public: * @param args Parameters to use to initialize the event. */ template - void publish(Args &&... args) { + void publish(Args &&...args) { Event instance{std::forward(args)...}; assure()->publish(instance, *static_cast(this)); } @@ -320,8 +316,6 @@ private: std::vector> pools{}; }; - -} - +} // namespace entt #endif diff --git a/src/entt/signal/fwd.hpp b/src/entt/signal/fwd.hpp index 950a1d54f..baa198e60 100644 --- a/src/entt/signal/fwd.hpp +++ b/src/entt/signal/fwd.hpp @@ -1,36 +1,26 @@ #ifndef ENTT_SIGNAL_FWD_HPP #define ENTT_SIGNAL_FWD_HPP - namespace entt { - template class delegate; - class dispatcher; - template class emitter; - class connection; - struct scoped_connection; - template class sink; - template class sigh; - -} - +} // namespace entt #endif diff --git a/src/entt/signal/sigh.hpp b/src/entt/signal/sigh.hpp index c39d6c9de..fe0a3737b 100644 --- a/src/entt/signal/sigh.hpp +++ b/src/entt/signal/sigh.hpp @@ -1,21 +1,18 @@ #ifndef ENTT_SIGNAL_SIGH_HPP #define ENTT_SIGNAL_SIGH_HPP - -#include -#include -#include #include #include +#include #include +#include +#include #include "../config/config.h" #include "delegate.hpp" #include "fwd.hpp" - namespace entt { - /** * @brief Sink class. * @@ -27,7 +24,6 @@ namespace entt { template class sink; - /** * @brief Unmanaged signal handler. * @@ -39,7 +35,6 @@ class sink; template class sigh; - /** * @brief Unmanaged signal handler. * @@ -141,7 +136,6 @@ private: std::vector> calls; }; - /** * @brief Connection class. * @@ -155,8 +149,7 @@ class connection { friend class sink; connection(delegate fn, void *ref) - : disconnect{fn}, signal{ref} - {} + : disconnect{fn}, signal{ref} {} public: /*! @brief Default constructor. */ @@ -183,7 +176,6 @@ private: void *signal{}; }; - /** * @brief Scoped connection class. * @@ -202,8 +194,7 @@ struct scoped_connection { * @param other A valid connection object. */ scoped_connection(const connection &other) - : conn{other} - {} + : conn{other} {} /*! @brief Default copy constructor, deleted on purpose. */ scoped_connection(const scoped_connection &) = delete; @@ -213,8 +204,7 @@ struct scoped_connection { * @param other The scoped connection to move from. */ scoped_connection(scoped_connection &&other) ENTT_NOEXCEPT - : conn{std::exchange(other.conn, {})} - {} + : conn{std::exchange(other.conn, {})} {} /*! @brief Automatically breaks the link on destruction. */ ~scoped_connection() { @@ -225,14 +215,14 @@ struct scoped_connection { * @brief Default copy assignment operator, deleted on purpose. * @return This scoped connection. */ - scoped_connection & operator=(const scoped_connection &) = delete; + scoped_connection &operator=(const scoped_connection &) = delete; /** * @brief Move assignment operator. * @param other The scoped connection to move from. * @return This scoped connection. */ - scoped_connection & operator=(scoped_connection &&other) ENTT_NOEXCEPT { + scoped_connection &operator=(scoped_connection &&other) ENTT_NOEXCEPT { conn = std::exchange(other.conn, {}); return *this; } @@ -242,7 +232,7 @@ struct scoped_connection { * @param other The connection object to acquire. * @return This scoped connection. */ - scoped_connection & operator=(connection other) { + scoped_connection &operator=(connection other) { conn = std::move(other); return *this; } @@ -264,7 +254,6 @@ private: connection conn; }; - /** * @brief Sink class. * @@ -305,8 +294,7 @@ public: */ sink(sigh &ref) ENTT_NOEXCEPT : offset{}, - signal{&ref} - {} + signal{&ref} {} /** * @brief Returns false if at least a listener is connected to the sink. @@ -420,7 +408,7 @@ public: delegate conn{}; conn.template connect<&release>(); - return { std::move(conn), signal }; + return {std::move(conn), signal}; } /** @@ -450,7 +438,7 @@ public: delegate conn{}; conn.template connect<&release>(value_or_instance); - return { std::move(conn), signal }; + return {std::move(conn), signal}; } /** @@ -516,7 +504,6 @@ private: signal_type *signal; }; - /** * @brief Deduction guide. * @@ -529,8 +516,6 @@ private: template sink(sigh &) -> sink; - -} - +} // namespace entt #endif diff --git a/test/benchmark/benchmark.cpp b/test/benchmark/benchmark.cpp index 18f52df98..654fcad24 100644 --- a/test/benchmark/benchmark.cpp +++ b/test/benchmark/benchmark.cpp @@ -1,7 +1,7 @@ -#include +#include #include #include -#include +#include #include #include #include @@ -24,7 +24,8 @@ struct entt::component_traits: basic_component_traits { }; struct timer final { - timer(): start{std::chrono::system_clock::now()} {} + timer() + : start{std::chrono::system_clock::now()} {} void elapsed() { auto now = std::chrono::system_clock::now(); @@ -62,7 +63,7 @@ void pathological(Func func) { } } - func(registry, [](auto &... comp) { + func(registry, [](auto &...comp) { ((comp.x = {}), ...); }); } @@ -304,7 +305,7 @@ TEST(Benchmark, IterateSingleComponent1M) { timer.elapsed(); }; - test([](auto &... comp) { + test([](auto &...comp) { ((comp.x = {}), ...); }); } @@ -325,7 +326,7 @@ TEST(Benchmark, IterateSingleComponentTombstonePolicy1M) { timer.elapsed(); }; - test([](auto &... comp) { + test([](auto &...comp) { ((comp.x = {}), ...); }); } @@ -341,7 +342,7 @@ TEST(Benchmark, IterateSingleComponentRuntime1M) { } auto test = [&](auto func) { - entt::id_type types[] = { entt::type_hash::value() }; + entt::id_type types[] = {entt::type_hash::value()}; timer timer; registry.runtime_view(std::begin(types), std::end(types)).each(func); @@ -370,7 +371,7 @@ TEST(Benchmark, IterateTwoComponents1M) { timer.elapsed(); }; - test([](auto &... comp) { + test([](auto &...comp) { ((comp.x = {}), ...); }); } @@ -392,7 +393,7 @@ TEST(Benchmark, IterateTombstonePolicyTwoComponentsTombstonePolicy1M) { timer.elapsed(); }; - test([](auto &... comp) { + test([](auto &...comp) { ((comp.x = {}), ...); }); } @@ -417,7 +418,7 @@ TEST(Benchmark, IterateTwoComponents1MHalf) { timer.elapsed(); }; - test([](auto &... comp) { + test([](auto &...comp) { ((comp.x = {}), ...); }); } @@ -442,7 +443,7 @@ TEST(Benchmark, IterateTwoComponents1MOne) { timer.elapsed(); }; - test([](auto &... comp) { + test([](auto &...comp) { ((comp.x = {}), ...); }); } @@ -465,7 +466,7 @@ TEST(Benchmark, IterateTwoComponentsNonOwningGroup1M) { timer.elapsed(); }; - test([](auto &... comp) { + test([](auto &...comp) { ((comp.x = {}), ...); }); } @@ -488,7 +489,7 @@ TEST(Benchmark, IterateTwoComponentsFullOwningGroup1M) { timer.elapsed(); }; - test([](auto &... comp) { + test([](auto &...comp) { ((comp.x = {}), ...); }); } @@ -511,7 +512,7 @@ TEST(Benchmark, IterateTwoComponentsPartialOwningGroup1M) { timer.elapsed(); }; - test([](auto &... comp) { + test([](auto &...comp) { ((comp.x = {}), ...); }); } @@ -530,8 +531,7 @@ TEST(Benchmark, IterateTwoComponentsRuntime1M) { auto test = [&](auto func) { entt::id_type types[] = { entt::type_hash::value(), - entt::type_hash::value() - }; + entt::type_hash::value()}; timer timer; registry.runtime_view(std::begin(types), std::end(types)).each(func); @@ -561,8 +561,7 @@ TEST(Benchmark, IterateTwoComponentsRuntime1MHalf) { auto test = [&](auto func) { entt::id_type types[] = { entt::type_hash::value(), - entt::type_hash::value() - }; + entt::type_hash::value()}; timer timer; registry.runtime_view(std::begin(types), std::end(types)).each(func); @@ -592,8 +591,7 @@ TEST(Benchmark, IterateTwoComponentsRuntime1MOne) { auto test = [&](auto func) { entt::id_type types[] = { entt::type_hash::value(), - entt::type_hash::value() - }; + entt::type_hash::value()}; timer timer; registry.runtime_view(std::begin(types), std::end(types)).each(func); @@ -624,7 +622,7 @@ TEST(Benchmark, IterateThreeComponents1M) { timer.elapsed(); }; - test([](auto &... comp) { + test([](auto &...comp) { ((comp.x = {}), ...); }); } @@ -647,7 +645,7 @@ TEST(Benchmark, IterateThreeComponentsTombstonePolicy1M) { timer.elapsed(); }; - test([](auto &... comp) { + test([](auto &...comp) { ((comp.x = {}), ...); }); } @@ -673,7 +671,7 @@ TEST(Benchmark, IterateThreeComponents1MHalf) { timer.elapsed(); }; - test([](auto &... comp) { + test([](auto &...comp) { ((comp.x = {}), ...); }); } @@ -699,7 +697,7 @@ TEST(Benchmark, IterateThreeComponents1MOne) { timer.elapsed(); }; - test([](auto &... comp) { + test([](auto &...comp) { ((comp.x = {}), ...); }); } @@ -723,7 +721,7 @@ TEST(Benchmark, IterateThreeComponentsNonOwningGroup1M) { timer.elapsed(); }; - test([](auto &... comp) { + test([](auto &...comp) { ((comp.x = {}), ...); }); } @@ -747,7 +745,7 @@ TEST(Benchmark, IterateThreeComponentsFullOwningGroup1M) { timer.elapsed(); }; - test([](auto &... comp) { + test([](auto &...comp) { ((comp.x = {}), ...); }); } @@ -771,7 +769,7 @@ TEST(Benchmark, IterateThreeComponentsPartialOwningGroup1M) { timer.elapsed(); }; - test([](auto &... comp) { + test([](auto &...comp) { ((comp.x = {}), ...); }); } @@ -792,8 +790,7 @@ TEST(Benchmark, IterateThreeComponentsRuntime1M) { entt::id_type types[] = { entt::type_hash::value(), entt::type_hash::value(), - entt::type_hash>::value() - }; + entt::type_hash>::value()}; timer timer; registry.runtime_view(std::begin(types), std::end(types)).each(func); @@ -826,8 +823,7 @@ TEST(Benchmark, IterateThreeComponentsRuntime1MHalf) { entt::id_type types[] = { entt::type_hash::value(), entt::type_hash::value(), - entt::type_hash>::value() - }; + entt::type_hash>::value()}; timer timer; registry.runtime_view(std::begin(types), std::end(types)).each(func); @@ -860,8 +856,7 @@ TEST(Benchmark, IterateThreeComponentsRuntime1MOne) { entt::id_type types[] = { entt::type_hash::value(), entt::type_hash::value(), - entt::type_hash>::value() - }; + entt::type_hash>::value()}; timer timer; registry.runtime_view(std::begin(types), std::end(types)).each(func); @@ -895,7 +890,7 @@ TEST(Benchmark, IterateFiveComponents1M) { timer.elapsed(); }; - test([](auto &... comp) { + test([](auto &...comp) { ((comp.x = {}), ...); }); } @@ -920,7 +915,7 @@ TEST(Benchmark, IterateFiveComponentsTombstonePolicy1M) { timer.elapsed(); }; - test([](auto &... comp) { + test([](auto &...comp) { ((comp.x = {}), ...); }); } @@ -948,7 +943,7 @@ TEST(Benchmark, IterateFiveComponents1MHalf) { timer.elapsed(); }; - test([](auto &... comp) { + test([](auto &...comp) { ((comp.x = {}), ...); }); } @@ -976,7 +971,7 @@ TEST(Benchmark, IterateFiveComponents1MOne) { timer.elapsed(); }; - test([](auto &... comp) { + test([](auto &...comp) { ((comp.x = {}), ...); }); } @@ -1002,7 +997,7 @@ TEST(Benchmark, IterateFiveComponentsNonOwningGroup1M) { timer.elapsed(); }; - test([](auto &... comp) { + test([](auto &...comp) { ((comp.x = {}), ...); }); } @@ -1028,7 +1023,7 @@ TEST(Benchmark, IterateFiveComponentsFullOwningGroup1M) { timer.elapsed(); }; - test([](auto &... comp) { + test([](auto &...comp) { ((comp.x = {}), ...); }); } @@ -1054,7 +1049,7 @@ TEST(Benchmark, IterateFiveComponentsPartialFourOfFiveOwningGroup1M) { timer.elapsed(); }; - test([](auto &... comp) { + test([](auto &...comp) { ((comp.x = {}), ...); }); } @@ -1080,7 +1075,7 @@ TEST(Benchmark, IterateFiveComponentsPartialThreeOfFiveOwningGroup1M) { timer.elapsed(); }; - test([](auto &... comp) { + test([](auto &...comp) { ((comp.x = {}), ...); }); } @@ -1105,8 +1100,7 @@ TEST(Benchmark, IterateFiveComponentsRuntime1M) { entt::type_hash::value(), entt::type_hash>::value(), entt::type_hash>::value(), - entt::type_hash>::value() - }; + entt::type_hash>::value()}; timer timer; registry.runtime_view(std::begin(types), std::end(types)).each(func); @@ -1145,8 +1139,7 @@ TEST(Benchmark, IterateFiveComponentsRuntime1MHalf) { entt::type_hash::value(), entt::type_hash>::value(), entt::type_hash>::value(), - entt::type_hash>::value() - }; + entt::type_hash>::value()}; timer timer; registry.runtime_view(std::begin(types), std::end(types)).each(func); @@ -1185,8 +1178,7 @@ TEST(Benchmark, IterateFiveComponentsRuntime1MOne) { entt::type_hash::value(), entt::type_hash>::value(), entt::type_hash>::value(), - entt::type_hash>::value() - }; + entt::type_hash>::value()}; timer timer; registry.runtime_view(std::begin(types), std::end(types)).each(func); diff --git a/test/entt/core/algorithm.cpp b/test/entt/core/algorithm.cpp index 520432054..9fd5c799e 100644 --- a/test/entt/core/algorithm.cpp +++ b/test/entt/core/algorithm.cpp @@ -14,7 +14,7 @@ TEST(Algorithm, StdSort) { sort(arr.begin(), arr.end()); for(auto i = 0u; i < (arr.size() - 1u); ++i) { - ASSERT_LT(arr[i], arr[i+1u]); + ASSERT_LT(arr[i], arr[i + 1u]); } } @@ -28,7 +28,7 @@ TEST(Algorithm, StdSortBoxedInt) { }); for(auto i = 0u; i < (arr.size() - 1u); ++i) { - ASSERT_GT(arr[i].value, arr[i+1u].value); + ASSERT_GT(arr[i].value, arr[i + 1u].value); } } @@ -39,7 +39,7 @@ TEST(Algorithm, InsertionSort) { sort(arr.begin(), arr.end()); for(auto i = 0u; i < (arr.size() - 1u); ++i) { - ASSERT_LT(arr[i], arr[i+1u]); + ASSERT_LT(arr[i], arr[i + 1u]); } } @@ -52,7 +52,7 @@ TEST(Algorithm, InsertionSortBoxedInt) { }); for(auto i = 0u; i < (arr.size() - 1u); ++i) { - ASSERT_GT(arr[i].value, arr[i+1u].value); + ASSERT_GT(arr[i].value, arr[i + 1u].value); } } @@ -72,7 +72,7 @@ TEST(Algorithm, RadixSort) { }); for(auto i = 0u; i < (arr.size() - 1u); ++i) { - ASSERT_LT(arr[i], arr[i+1u]); + ASSERT_LT(arr[i], arr[i + 1u]); } } @@ -85,7 +85,7 @@ TEST(Algorithm, RadixSortBoxedInt) { }); for(auto i = 0u; i < (arr.size() - 1u); ++i) { - ASSERT_GT(arr[i].value, arr[i+1u].value); + ASSERT_GT(arr[i].value, arr[i + 1u].value); } } diff --git a/test/entt/core/any.cpp b/test/entt/core/any.cpp index eed3189f0..228a20d6b 100644 --- a/test/entt/core/any.cpp +++ b/test/entt/core/any.cpp @@ -7,17 +7,20 @@ #include struct empty { - ~empty() { ++counter; } + ~empty() { + ++counter; + } inline static int counter = 0; }; struct fat { fat(double v1, double v2, double v3, double v4) - : value{v1, v2, v3, v4} - {} + : value{v1, v2, v3, v4} {} - ~fat() { ++counter; } + ~fat() { + ++counter; + } bool operator==(const fat &other) const { return std::equal(std::begin(value), std::end(value), std::begin(other.value), std::end(other.value)); @@ -33,11 +36,15 @@ struct not_comparable { template struct not_copyable { - not_copyable(): payload{} {} + not_copyable() + : payload{} {} + not_copyable(const not_copyable &) = delete; not_copyable(not_copyable &&) = default; - not_copyable & operator=(const not_copyable &) = delete; - not_copyable & operator=(not_copyable &&) = default; + + not_copyable &operator=(const not_copyable &) = delete; + not_copyable &operator=(not_copyable &&) = default; + double payload[Sz]; }; @@ -560,7 +567,7 @@ TEST_F(Any, EmplaceVoid) { ASSERT_FALSE(any); ASSERT_TRUE(any.owner()); ASSERT_EQ(any.type(), entt::type_id()); - } +} TEST_F(Any, Reset) { entt::any any{42}; @@ -1136,15 +1143,17 @@ TEST_F(Any, Alignment) { cb(data, target[1].data()); }; - entt::basic_any nosbo[2] = { over_aligned{}, over_aligned{} }; + entt::basic_any nosbo[2] = {over_aligned{}, over_aligned{}}; test(nosbo, [](auto *pre, auto *post) { ASSERT_EQ(pre, post); }); - entt::basic_any sbo[2] = { over_aligned{}, over_aligned{} }; + entt::basic_any sbo[2] = {over_aligned{}, over_aligned{}}; test(sbo, [](auto *pre, auto *post) { ASSERT_NE(pre, post); }); } TEST_F(Any, AggregatesMustWork) { - struct aggregate_type { int value; }; + struct aggregate_type { + int value; + }; // the goal of this test is to enforce the requirements for aggregate types entt::any{std::in_place_type, 42}.emplace(42); diff --git a/test/entt/core/compressed_pair.cpp b/test/entt/core/compressed_pair.cpp index 09b11ffdb..d375ac03f 100644 --- a/test/entt/core/compressed_pair.cpp +++ b/test/entt/core/compressed_pair.cpp @@ -7,20 +7,23 @@ struct empty_type {}; struct move_only_type { - move_only_type(): value{new int{99}} {} + move_only_type() + : value{new int{99}} {} - move_only_type(int v): value{new int{v}} {} + move_only_type(int v) + : value{new int{v}} {} - ~move_only_type() { delete value; } + ~move_only_type() { + delete value; + } move_only_type(const move_only_type &) = delete; - move_only_type & operator=(const move_only_type &) = delete; + move_only_type &operator=(const move_only_type &) = delete; move_only_type(move_only_type &&other) ENTT_NOEXCEPT - : value{std::exchange(other.value, nullptr)} - {} + : value{std::exchange(other.value, nullptr)} {} - move_only_type & operator=(move_only_type &&other) ENTT_NOEXCEPT { + move_only_type &operator=(move_only_type &&other) ENTT_NOEXCEPT { delete value; value = std::exchange(other.value, nullptr); return *this; @@ -30,7 +33,8 @@ struct move_only_type { }; struct non_default_constructible { - non_default_constructible(int v): value{v} {} + non_default_constructible(int v) + : value{v} {} int value; }; diff --git a/test/entt/core/enum.cpp b/test/entt/core/enum.cpp index 15e951d6a..b4cb8da59 100644 --- a/test/entt/core/enum.cpp +++ b/test/entt/core/enum.cpp @@ -17,8 +17,7 @@ enum class registered { template<> struct entt::enum_as_bitmask - : std::true_type -{}; + : std::true_type {}; TEST(Enum, Functionalities) { auto test = [](auto identity) { diff --git a/test/entt/core/memory.cpp b/test/entt/core/memory.cpp index 5e64f0514..cb8353606 100644 --- a/test/entt/core/memory.cpp +++ b/test/entt/core/memory.cpp @@ -9,7 +9,7 @@ struct test_allocator: std::allocator { using std::allocator::allocator; - test_allocator & operator=(const test_allocator &other) { + test_allocator &operator=(const test_allocator &other) { // necessary to avoid call suppression base::operator=(other); return *this; diff --git a/test/entt/core/tuple.cpp b/test/entt/core/tuple.cpp index d4e963dc5..b5e907a25 100644 --- a/test/entt/core/tuple.cpp +++ b/test/entt/core/tuple.cpp @@ -3,23 +3,23 @@ #include TEST(Tuple, UnwrapTuple) { - auto single = std::make_tuple(42); - auto multi = std::make_tuple(42, 'c'); - auto ref = std::forward_as_tuple(std::get<0>(single)); + auto single = std::make_tuple(42); + auto multi = std::make_tuple(42, 'c'); + auto ref = std::forward_as_tuple(std::get<0>(single)); - ASSERT_TRUE((std::is_same_v)); - ASSERT_TRUE((std::is_same_v &>)); - ASSERT_TRUE((std::is_same_v)); + ASSERT_TRUE((std::is_same_v)); + ASSERT_TRUE((std::is_same_v &>)); + ASSERT_TRUE((std::is_same_v)); - ASSERT_TRUE((std::is_same_v)); - ASSERT_TRUE((std::is_same_v &&>)); - ASSERT_TRUE((std::is_same_v)); + ASSERT_TRUE((std::is_same_v)); + ASSERT_TRUE((std::is_same_v &&>)); + ASSERT_TRUE((std::is_same_v)); - ASSERT_TRUE((std::is_same_v)); - ASSERT_TRUE((std::is_same_v &>)); - ASSERT_TRUE((std::is_same_v)); + ASSERT_TRUE((std::is_same_v)); + ASSERT_TRUE((std::is_same_v &>)); + ASSERT_TRUE((std::is_same_v)); - ASSERT_EQ(entt::unwrap_tuple(single), 42); - ASSERT_EQ(entt::unwrap_tuple(multi), multi); - ASSERT_EQ(entt::unwrap_tuple(std::move(ref)), 42); + ASSERT_EQ(entt::unwrap_tuple(single), 42); + ASSERT_EQ(entt::unwrap_tuple(multi), multi); + ASSERT_EQ(entt::unwrap_tuple(std::move(ref)), 42); } diff --git a/test/entt/core/type_info.cpp b/test/entt/core/type_info.cpp index 5982dc1c9..97265e074 100644 --- a/test/entt/core/type_info.cpp +++ b/test/entt/core/type_info.cpp @@ -32,11 +32,11 @@ TEST(TypeName, Functionalities) { ASSERT_EQ(entt::type_name{}.value(), std::string_view{""}); ASSERT_TRUE((entt::type_name>::value() == std::string_view{"std::integral_constant"}) - || (entt::type_name>::value() == std::string_view{"std::__1::integral_constant"}) - || (entt::type_name>::value() == std::string_view{"struct std::integral_constant"})); + || (entt::type_name>::value() == std::string_view{"std::__1::integral_constant"}) + || (entt::type_name>::value() == std::string_view{"struct std::integral_constant"})); ASSERT_TRUE(((entt::type_name, double>>::value()) == std::string_view{"entt::type_list, double>"}) - || ((entt::type_name, double>>::value()) == std::string_view{"struct entt::type_list,double>"})); + || ((entt::type_name, double>>::value()) == std::string_view{"struct entt::type_list,double>"})); ASSERT_EQ(static_cast(entt::type_name{}), entt::type_name::value()); } diff --git a/test/entt/core/type_traits.cpp b/test/entt/core/type_traits.cpp index 29e163498..08c9094f7 100644 --- a/test/entt/core/type_traits.cpp +++ b/test/entt/core/type_traits.cpp @@ -15,7 +15,9 @@ struct not_comparable { struct nlohmann_json_like { using value_type = nlohmann_json_like; - bool operator==(const nlohmann_json_like &) const { return true; } + bool operator==(const nlohmann_json_like &) const { + return true; + } }; TEST(TypeTraits, SizeOf) { @@ -160,9 +162,13 @@ TEST(TypeTraits, ConstnessAs) { TEST(TypeTraits, MemberClass) { struct clazz { - char foo(int) { return {}; } + char foo(int) { + return {}; + } - int bar(double, float) const { return {}; } + int bar(double, float) const { + return {}; + } bool quux; }; diff --git a/test/entt/core/utility.cpp b/test/entt/core/utility.cpp index 18d6b9abe..a97260a0f 100644 --- a/test/entt/core/utility.cpp +++ b/test/entt/core/utility.cpp @@ -19,11 +19,11 @@ TEST(Utility, Identity) { } TEST(Utility, Overload) { - ASSERT_EQ(entt::overload(&functions::foo), static_cast(&functions::foo)); - ASSERT_EQ(entt::overload(&functions::foo), static_cast(&functions::foo)); + ASSERT_EQ(entt::overload(&functions::foo), static_cast(&functions::foo)); + ASSERT_EQ(entt::overload(&functions::foo), static_cast(&functions::foo)); - ASSERT_EQ(entt::overload(&functions::bar), static_cast(&functions::bar)); - ASSERT_EQ(entt::overload(&functions::bar), static_cast(&functions::bar)); + ASSERT_EQ(entt::overload(&functions::bar), static_cast(&functions::bar)); + ASSERT_EQ(entt::overload(&functions::bar), static_cast(&functions::bar)); functions instance; @@ -40,8 +40,7 @@ TEST(Utility, Overloaded) { entt::overloaded func{ [&iv](int value) { iv = value; }, - [&cv](char value) { cv = value; } - }; + [&cv](char value) { cv = value; }}; func(42); func('c'); @@ -52,9 +51,9 @@ TEST(Utility, Overloaded) { TEST(Utility, YCombinator) { entt::y_combinator gauss([](const auto &self, auto value) -> unsigned int { - return value ? (value + self(value-1u)) : 0; + return value ? (value + self(value - 1u)) : 0; }); - ASSERT_EQ(gauss(3u), 3u*4u/2u); - ASSERT_EQ(std::as_const(gauss)(7u), 7u*8u/2u); + ASSERT_EQ(gauss(3u), 3u * 4u / 2u); + ASSERT_EQ(std::as_const(gauss)(7u), 7u * 8u / 2u); } diff --git a/test/entt/entity/group.cpp b/test/entt/entity/group.cpp index 38a92dd8f..20ce542ad 100644 --- a/test/entt/entity/group.cpp +++ b/test/entt/entity/group.cpp @@ -3,12 +3,14 @@ #include #include #include -#include #include +#include struct empty_type {}; -struct boxed_int { int value; }; +struct boxed_int { + int value; +}; bool operator==(const boxed_int &lhs, const boxed_int &rhs) { return lhs.value == rhs.value; @@ -286,7 +288,7 @@ TEST(NonOwningGroup, SortAsAPool) { registry.emplace(e0, uval++); registry.emplace(e1, uval++); registry.emplace(e2, uval++); - registry.emplace(e3, uval+1); + registry.emplace(e3, uval + 1); registry.emplace(e0, ival++); registry.emplace(e1, ival++); @@ -1067,7 +1069,7 @@ TEST(OwningGroup, ConstNonConstAndAllInBetween) { static_assert(std::is_same_v({})), std::tuple>); static_assert(std::is_same_v>); static_assert(std::is_same_v); - static_assert(std::is_same_v()), const char * const *>); + static_assert(std::is_same_v()), const char *const *>); static_assert(std::is_same_v()), int **>); static_assert(std::is_same_v(entt::get)), decltype(std::as_const(registry).group_if_exists(entt::get))>); diff --git a/test/entt/entity/handle.cpp b/test/entt/entity/handle.cpp index 2664fada7..d6cd43211 100644 --- a/test/entt/entity/handle.cpp +++ b/test/entt/entity/handle.cpp @@ -51,7 +51,7 @@ TEST(BasicHandle, Invalidation) { entt::registry registry; const auto entity = registry.create(); - handle = { registry, entity }; + handle = {registry, entity}; ASSERT_TRUE(handle); ASSERT_NE(handle.registry(), nullptr); @@ -137,8 +137,8 @@ TEST(BasicHandle, Comparison) { entt::registry other; const auto entt = other.create(); - handle = { registry, entity }; - chandle = { other, entt }; + handle = {registry, entity}; + chandle = {other, entt}; ASSERT_NE(handle, chandle); ASSERT_FALSE(chandle == handle); diff --git a/test/entt/entity/helper.cpp b/test/entt/entity/helper.cpp index aedf038ae..43faf1237 100644 --- a/test/entt/entity/helper.cpp +++ b/test/entt/entity/helper.cpp @@ -1,12 +1,14 @@ #include #include -#include -#include -#include #include +#include +#include +#include struct clazz { - void func(entt::registry &, entt::entity curr) { entt = curr; } + void func(entt::registry &, entt::entity curr) { + entt = curr; + } entt::entity entt{entt::null}; }; diff --git a/test/entt/entity/observer.cpp b/test/entt/entity/observer.cpp index 07950af6e..6bb420e82 100644 --- a/test/entt/entity/observer.cpp +++ b/test/entt/entity/observer.cpp @@ -1,5 +1,5 @@ -#include #include +#include #include #include #include @@ -88,7 +88,8 @@ TEST(Observer, AllOf) { TEST(Observer, AllOfFiltered) { constexpr auto collector = entt::collector - .group().where(entt::exclude); + .group() + .where(entt::exclude); entt::registry registry; entt::observer observer{registry, collector}; @@ -168,7 +169,8 @@ TEST(Observer, Observe) { TEST(Observer, ObserveFiltered) { constexpr auto collector = entt::collector - .update().where(entt::exclude); + .update() + .where(entt::exclude); entt::registry registry; entt::observer observer{registry, collector}; @@ -287,8 +289,10 @@ TEST(Observer, Each) { TEST(Observer, MultipleFilters) { constexpr auto collector = entt::collector - .update().where() - .update().where(); + .update() + .where() + .update() + .where(); entt::registry registry; entt::observer observer{registry, collector}; diff --git a/test/entt/entity/poly_storage.cpp b/test/entt/entity/poly_storage.cpp index 70e08578d..a1d431169 100644 --- a/test/entt/entity/poly_storage.cpp +++ b/test/entt/entity/poly_storage.cpp @@ -15,10 +15,7 @@ struct PolyStorage void(const Entity *, const Entity *, void *), void(entt::basic_registry &, const Entity, const void *), const void *(const Entity) const, - void(entt::basic_registry &) const - > - > -{ + void(entt::basic_registry &) const>> { using entity_type = Entity; using size_type = std::size_t; @@ -34,7 +31,7 @@ struct PolyStorage entt::poly_call(*this, owner, entity, instance); } - const void * get(const entity_type entity) const { + const void *get(const entity_type entity) const { return entt::poly_call(*this, entity); } @@ -49,7 +46,7 @@ struct PolyStorage self.emplace(owner, entity, *static_cast(instance)); } - static const typename Type::value_type * get(const Type &self, const entity_type entity) { + static const typename Type::value_type *get(const Type &self, const entity_type entity) { return &self.get(entity); } @@ -66,9 +63,7 @@ struct PolyStorage &Type::template erase, &members::emplace, &members::get, - &members::copy_to - > - >; + &members::copy_to>>; }; template diff --git a/test/entt/entity/registry.cpp b/test/entt/entity/registry.cpp index 480470106..881a12a9b 100644 --- a/test/entt/entity/registry.cpp +++ b/test/entt/entity/registry.cpp @@ -1,9 +1,9 @@ -#include +#include #include #include #include -#include #include +#include #include #include #include @@ -12,7 +12,9 @@ struct empty_type {}; -struct stable_type { int value; }; +struct stable_type { + int value; +}; template<> struct entt::component_traits: basic_component_traits { @@ -20,7 +22,8 @@ struct entt::component_traits: basic_component_traits { }; struct non_default_constructible { - non_default_constructible(int v): value{v} {} + non_default_constructible(int v) + : value{v} {} int value; }; @@ -939,7 +942,6 @@ TEST(Registry, PartialOwningGroupInitOnFirstUse) { ASSERT_FALSE(registry.sortable()); ASSERT_TRUE(registry.sortable()); ASSERT_EQ(cnt, 2u); - } TEST(Registry, PartialOwningGroupInitOnEmplace) { @@ -1107,28 +1109,28 @@ TEST(Registry, NestedGroups) { ASSERT_EQ(g2.size(), 10u); for(auto i = 0u; i < 5u; ++i) { - ASSERT_TRUE(g1.contains(entities[i*2+1])); - ASSERT_TRUE(g1.contains(entities[i*2])); - ASSERT_TRUE(g2.contains(entities[i*2+1])); - ASSERT_TRUE(g2.contains(entities[i*2])); - registry.emplace(entities[i*2]); + ASSERT_TRUE(g1.contains(entities[i * 2 + 1])); + ASSERT_TRUE(g1.contains(entities[i * 2])); + ASSERT_TRUE(g2.contains(entities[i * 2 + 1])); + ASSERT_TRUE(g2.contains(entities[i * 2])); + registry.emplace(entities[i * 2]); } ASSERT_EQ(g1.size(), 5u); ASSERT_EQ(g2.size(), 10u); for(auto i = 0u; i < 5u; ++i) { - ASSERT_TRUE(g1.contains(entities[i*2+1])); - ASSERT_FALSE(g1.contains(entities[i*2])); - ASSERT_TRUE(g2.contains(entities[i*2+1])); - ASSERT_TRUE(g2.contains(entities[i*2])); - registry.erase(entities[i*2+1]); + ASSERT_TRUE(g1.contains(entities[i * 2 + 1])); + ASSERT_FALSE(g1.contains(entities[i * 2])); + ASSERT_TRUE(g2.contains(entities[i * 2 + 1])); + ASSERT_TRUE(g2.contains(entities[i * 2])); + registry.erase(entities[i * 2 + 1]); } ASSERT_EQ(g1.size(), 0u); ASSERT_EQ(g2.size(), 5u); - const auto g3= registry.group(entt::get, entt::exclude); + const auto g3 = registry.group(entt::get, entt::exclude); ASSERT_FALSE(registry.sortable(g1)); ASSERT_FALSE(registry.sortable(g2)); @@ -1139,13 +1141,13 @@ TEST(Registry, NestedGroups) { ASSERT_EQ(g3.size(), 0u); for(auto i = 0u; i < 5u; ++i) { - ASSERT_FALSE(g1.contains(entities[i*2+1])); - ASSERT_FALSE(g1.contains(entities[i*2])); - ASSERT_FALSE(g2.contains(entities[i*2+1])); - ASSERT_TRUE(g2.contains(entities[i*2])); - ASSERT_FALSE(g3.contains(entities[i*2+1])); - ASSERT_FALSE(g3.contains(entities[i*2])); - registry.emplace(entities[i*2+1]); + ASSERT_FALSE(g1.contains(entities[i * 2 + 1])); + ASSERT_FALSE(g1.contains(entities[i * 2])); + ASSERT_FALSE(g2.contains(entities[i * 2 + 1])); + ASSERT_TRUE(g2.contains(entities[i * 2])); + ASSERT_FALSE(g3.contains(entities[i * 2 + 1])); + ASSERT_FALSE(g3.contains(entities[i * 2])); + registry.emplace(entities[i * 2 + 1]); } ASSERT_EQ(g1.size(), 5u); @@ -1153,13 +1155,13 @@ TEST(Registry, NestedGroups) { ASSERT_EQ(g3.size(), 0u); for(auto i = 0u; i < 5u; ++i) { - ASSERT_TRUE(g1.contains(entities[i*2+1])); - ASSERT_FALSE(g1.contains(entities[i*2])); - ASSERT_TRUE(g2.contains(entities[i*2+1])); - ASSERT_TRUE(g2.contains(entities[i*2])); - ASSERT_FALSE(g3.contains(entities[i*2+1])); - ASSERT_FALSE(g3.contains(entities[i*2])); - registry.emplace(entities[i*2]); + ASSERT_TRUE(g1.contains(entities[i * 2 + 1])); + ASSERT_FALSE(g1.contains(entities[i * 2])); + ASSERT_TRUE(g2.contains(entities[i * 2 + 1])); + ASSERT_TRUE(g2.contains(entities[i * 2])); + ASSERT_FALSE(g3.contains(entities[i * 2 + 1])); + ASSERT_FALSE(g3.contains(entities[i * 2])); + registry.emplace(entities[i * 2]); } ASSERT_EQ(g1.size(), 5u); @@ -1167,7 +1169,7 @@ TEST(Registry, NestedGroups) { ASSERT_EQ(g3.size(), 0u); for(auto i = 0u; i < 5u; ++i) { - registry.erase(entities[i*2]); + registry.erase(entities[i * 2]); } ASSERT_EQ(g1.size(), 10u); @@ -1175,14 +1177,14 @@ TEST(Registry, NestedGroups) { ASSERT_EQ(g3.size(), 5u); for(auto i = 0u; i < 5u; ++i) { - ASSERT_TRUE(g1.contains(entities[i*2+1])); - ASSERT_TRUE(g1.contains(entities[i*2])); - ASSERT_TRUE(g2.contains(entities[i*2+1])); - ASSERT_TRUE(g2.contains(entities[i*2])); - ASSERT_FALSE(g3.contains(entities[i*2+1])); - ASSERT_TRUE(g3.contains(entities[i*2])); - registry.erase(entities[i*2+1]); - registry.erase(entities[i*2]); + ASSERT_TRUE(g1.contains(entities[i * 2 + 1])); + ASSERT_TRUE(g1.contains(entities[i * 2])); + ASSERT_TRUE(g2.contains(entities[i * 2 + 1])); + ASSERT_TRUE(g2.contains(entities[i * 2])); + ASSERT_FALSE(g3.contains(entities[i * 2 + 1])); + ASSERT_TRUE(g3.contains(entities[i * 2])); + registry.erase(entities[i * 2 + 1]); + registry.erase(entities[i * 2]); } ASSERT_EQ(g1.size(), 0u); diff --git a/test/entt/entity/runtime_view.cpp b/test/entt/entity/runtime_view.cpp index 688597b45..0961e61ea 100644 --- a/test/entt/entity/runtime_view.cpp +++ b/test/entt/entity/runtime_view.cpp @@ -1,12 +1,14 @@ -#include #include +#include #include #include #include #include #include -struct stable_type { int value; }; +struct stable_type { + int value; +}; template<> struct entt::component_traits: basic_component_traits { @@ -20,7 +22,7 @@ TEST(RuntimeView, Functionalities) { registry.reserve(0); registry.reserve(0); - entt::id_type types[] = { entt::type_hash::value(), entt::type_hash::value() }; + entt::id_type types[] = {entt::type_hash::value(), entt::type_hash::value()}; auto view = registry.runtime_view(std::begin(types), std::end(types)); ASSERT_EQ(view.size_hint(), 0u); @@ -68,7 +70,7 @@ TEST(RuntimeView, Iterator) { registry.emplace(entity); registry.emplace(entity); - entt::id_type types[] = { entt::type_hash::value(), entt::type_hash::value() }; + entt::id_type types[] = {entt::type_hash::value(), entt::type_hash::value()}; auto view = registry.runtime_view(std::begin(types), std::end(types)); using iterator = typename decltype(view)::iterator; @@ -104,7 +106,7 @@ TEST(RuntimeView, Contains) { registry.destroy(e0); - entt::id_type types[] = { entt::type_hash::value(), entt::type_hash::value() }; + entt::id_type types[] = {entt::type_hash::value(), entt::type_hash::value()}; auto view = registry.runtime_view(std::begin(types), std::end(types)); ASSERT_FALSE(view.contains(e0)); @@ -123,7 +125,7 @@ TEST(RuntimeView, Empty) { registry.emplace(e1); registry.emplace(e1); - entt::id_type types[] = { entt::type_hash::value(), entt::type_hash::value(), entt::type_hash::value() }; + entt::id_type types[] = {entt::type_hash::value(), entt::type_hash::value(), entt::type_hash::value()}; auto view = registry.runtime_view(std::begin(types), std::end(types)); view.each([](auto) { FAIL(); }); @@ -143,7 +145,7 @@ TEST(RuntimeView, Each) { registry.emplace(e1); registry.emplace(e1); - entt::id_type types[] = { entt::type_hash::value(), entt::type_hash::value() }; + entt::id_type types[] = {entt::type_hash::value(), entt::type_hash::value()}; auto view = registry.runtime_view(std::begin(types), std::end(types)); std::size_t cnt = 0; @@ -165,7 +167,7 @@ TEST(RuntimeView, EachWithHoles) { registry.emplace(e0, 0); registry.emplace(e2, 2); - entt::id_type types[] = { entt::type_hash::value(), entt::type_hash::value() }; + entt::id_type types[] = {entt::type_hash::value(), entt::type_hash::value()}; auto view = registry.runtime_view(std::begin(types), std::end(types)); view.each([e0](auto entity) { @@ -179,7 +181,7 @@ TEST(RuntimeView, MissingPool) { const auto e0 = registry.create(); registry.emplace(e0); - entt::id_type types[] = { entt::type_hash::value(), entt::type_hash::value() }; + entt::id_type types[] = {entt::type_hash::value(), entt::type_hash::value()}; auto view = registry.runtime_view(std::begin(types), std::end(types)); ASSERT_EQ(view.size_hint(), 0u); @@ -221,8 +223,8 @@ TEST(RuntimeView, ExcludedComponents) { registry.emplace(e1); registry.emplace(e1); - entt::id_type components[] = { entt::type_hash::value() }; - entt::id_type filter[] = { entt::type_hash::value(), entt::type_hash::value() }; + entt::id_type components[] = {entt::type_hash::value()}; + entt::id_type filter[] = {entt::type_hash::value(), entt::type_hash::value()}; auto view = registry.runtime_view(std::begin(components), std::end(components), std::begin(filter), std::end(filter)); ASSERT_TRUE(view.contains(e0)); @@ -249,7 +251,7 @@ TEST(RuntimeView, StableType) { registry.remove(e1); - entt::id_type components[] = { entt::type_hash::value(), entt::type_hash::value() }; + entt::id_type components[] = {entt::type_hash::value(), entt::type_hash::value()}; auto view = registry.runtime_view(std::begin(components), std::end(components)); ASSERT_EQ(view.size_hint(), 2u); diff --git a/test/entt/entity/sigh_storage_mixin.cpp b/test/entt/entity/sigh_storage_mixin.cpp index 57539bf8c..1edc624d6 100644 --- a/test/entt/entity/sigh_storage_mixin.cpp +++ b/test/entt/entity/sigh_storage_mixin.cpp @@ -6,12 +6,16 @@ #include struct empty_type {}; -struct stable_type { int value; }; + +struct stable_type { + int value; +}; struct non_default_constructible { non_default_constructible() = delete; - non_default_constructible(int v): value{v} {} + non_default_constructible(int v) + : value{v} {} int value; }; diff --git a/test/entt/entity/snapshot.cpp b/test/entt/entity/snapshot.cpp index 0f19eca51..d024775de 100644 --- a/test/entt/entity/snapshot.cpp +++ b/test/entt/entity/snapshot.cpp @@ -1,22 +1,25 @@ #include -#include #include -#include +#include #include +#include #include +#include #include #include -#include struct noncopyable_component { - noncopyable_component(): value{} {} - explicit noncopyable_component(int v): value{v} {} + noncopyable_component() + : value{} {} + + explicit noncopyable_component(int v) + : value{v} {} noncopyable_component(const noncopyable_component &) = delete; noncopyable_component(noncopyable_component &&) = default; - noncopyable_component& operator=(const noncopyable_component &) = delete; - noncopyable_component& operator=(noncopyable_component &&) = default; + noncopyable_component &operator=(const noncopyable_component &) = delete; + noncopyable_component &operator=(noncopyable_component &&) = default; int value; }; @@ -24,11 +27,10 @@ struct noncopyable_component { template struct output_archive { output_archive(Storage &instance) - : storage{instance} - {} + : storage{instance} {} template - void operator()(const Value &... value) { + void operator()(const Value &...value) { (std::get>(storage).push(value), ...); } @@ -43,11 +45,10 @@ private: template struct input_archive { input_archive(Storage &instance) - : storage{instance} - {} + : storage{instance} {} template - void operator()(Value &... value) { + void operator()(Value &...value) { auto assign = [this](auto &val) { auto &queue = std::get>>(storage); val = queue.front(); @@ -112,8 +113,7 @@ TEST(Snapshot, Dump) { std::queue, std::queue, std::queue, - std::queue - >; + std::queue>; storage_type storage; output_archive output{storage}; @@ -175,8 +175,7 @@ TEST(Snapshot, Partial) { std::queue, std::queue, std::queue, - std::queue - >; + std::queue>; storage_type storage; output_archive output{storage}; @@ -239,8 +238,7 @@ TEST(Snapshot, Iterator) { std::queue, std::queue, std::queue, - std::queue - >; + std::queue>; storage_type storage; output_archive output{storage}; @@ -278,8 +276,7 @@ TEST(Snapshot, Continuous) { std::queue, std::queue, std::queue, - std::queue - >; + std::queue>; storage_type storage; output_archive output{storage}; @@ -332,8 +329,8 @@ TEST(Snapshot, Continuous) { &what_a_component::quux, &map_component::keys, &map_component::values, - &map_component::both - ).orphans(); + &map_component::both) + .orphans(); decltype(dst.size()) a_component_cnt{}; decltype(dst.size()) another_component_cnt{}; @@ -398,8 +395,8 @@ TEST(Snapshot, Continuous) { &what_a_component::quux, &map_component::keys, &map_component::values, - &map_component::both - ).orphans(); + &map_component::both) + .orphans(); ASSERT_EQ(size, dst.size()); @@ -428,8 +425,8 @@ TEST(Snapshot, Continuous) { &what_a_component::quux, &map_component::keys, &map_component::values, - &map_component::both - ).orphans(); + &map_component::both) + .orphans(); dst.view().each([&loader, entity](auto, auto &component) { ASSERT_EQ(component.bar, loader.map(entity)); @@ -452,8 +449,9 @@ TEST(Snapshot, Continuous) { &what_a_component::quux, &map_component::keys, &map_component::values, - &map_component::both - ).orphans().shrink(); + &map_component::both) + .orphans() + .shrink(); dst.view().each([&dst](auto, auto &component) { ASSERT_FALSE(dst.valid(component.bar)); @@ -479,8 +477,8 @@ TEST(Snapshot, Continuous) { &what_a_component::quux, &map_component::keys, &map_component::values, - &map_component::both - ).orphans(); + &map_component::both) + .orphans(); ASSERT_EQ(dst.size(), a_component_cnt); @@ -496,8 +494,8 @@ TEST(Snapshot, Continuous) { &what_a_component::quux, &map_component::keys, &map_component::values, - &map_component::both - ).orphans(); + &map_component::both) + .orphans(); ASSERT_EQ(dst.size(), a_component_cnt); } @@ -512,8 +510,7 @@ TEST(Snapshot, MoreOnShrink) { using storage_type = std::tuple< std::queue, - std::queue - >; + std::queue>; storage_type storage; output_archive output{storage}; @@ -542,8 +539,7 @@ TEST(Snapshot, SyncDataMembers) { std::queue, std::queue, std::queue, - std::queue - >; + std::queue>; storage_type storage; output_archive output{storage}; @@ -557,16 +553,14 @@ TEST(Snapshot, SyncDataMembers) { auto parent = src.create(); auto child = src.create(); - src.emplace(parent, entt::null); src.emplace(child, parent).quux.push_back(child); src.emplace( child, - decltype(map_component::keys){{{ child, 10 }}}, - decltype(map_component::values){{{ 10, child }}}, - decltype(map_component::both){{{ child, child }}} - ); + decltype(map_component::keys){{{child, 10}}}, + decltype(map_component::values){{{10, child}}}, + decltype(map_component::both){{{child, child}}}); entt::snapshot{src}.entities(output).component(output); @@ -576,8 +570,7 @@ TEST(Snapshot, SyncDataMembers) { &what_a_component::quux, &map_component::keys, &map_component::values, - &map_component::both - ); + &map_component::both); ASSERT_FALSE(dst.valid(parent)); ASSERT_FALSE(dst.valid(child)); diff --git a/test/entt/entity/sparse_set.cpp b/test/entt/entity/sparse_set.cpp index 61c0d2cbb..7834c8795 100644 --- a/test/entt/entity/sparse_set.cpp +++ b/test/entt/entity/sparse_set.cpp @@ -1,9 +1,9 @@ -#include -#include -#include #include +#include #include +#include #include +#include #include #include #include @@ -11,7 +11,9 @@ struct empty_type {}; -struct boxed_int { int value; }; +struct boxed_int { + int value; +}; TEST(SparseSet, Functionalities) { entt::sparse_set set; @@ -218,29 +220,29 @@ TEST(SparseSet, Pagination) { ASSERT_EQ(set.extent(), 0u); - set.emplace(entt::entity{ENTT_SPARSE_PAGE-1u}); + set.emplace(entt::entity{ENTT_SPARSE_PAGE - 1u}); ASSERT_EQ(set.extent(), ENTT_SPARSE_PAGE); - ASSERT_TRUE(set.contains(entt::entity{ENTT_SPARSE_PAGE-1u})); + ASSERT_TRUE(set.contains(entt::entity{ENTT_SPARSE_PAGE - 1u})); set.emplace(entt::entity{ENTT_SPARSE_PAGE}); ASSERT_EQ(set.extent(), 2 * ENTT_SPARSE_PAGE); - ASSERT_TRUE(set.contains(entt::entity{ENTT_SPARSE_PAGE-1u})); + ASSERT_TRUE(set.contains(entt::entity{ENTT_SPARSE_PAGE - 1u})); ASSERT_TRUE(set.contains(entt::entity{ENTT_SPARSE_PAGE})); - ASSERT_FALSE(set.contains(entt::entity{ENTT_SPARSE_PAGE+1u})); + ASSERT_FALSE(set.contains(entt::entity{ENTT_SPARSE_PAGE + 1u})); - set.erase(entt::entity{ENTT_SPARSE_PAGE-1u}); + set.erase(entt::entity{ENTT_SPARSE_PAGE - 1u}); ASSERT_EQ(set.extent(), 2 * ENTT_SPARSE_PAGE); - ASSERT_FALSE(set.contains(entt::entity{ENTT_SPARSE_PAGE-1u})); + ASSERT_FALSE(set.contains(entt::entity{ENTT_SPARSE_PAGE - 1u})); ASSERT_TRUE(set.contains(entt::entity{ENTT_SPARSE_PAGE})); set.shrink_to_fit(); set.erase(entt::entity{ENTT_SPARSE_PAGE}); ASSERT_EQ(set.extent(), 2 * ENTT_SPARSE_PAGE); - ASSERT_FALSE(set.contains(entt::entity{ENTT_SPARSE_PAGE-1u})); + ASSERT_FALSE(set.contains(entt::entity{ENTT_SPARSE_PAGE - 1u})); ASSERT_FALSE(set.contains(entt::entity{ENTT_SPARSE_PAGE})); set.shrink_to_fit(); @@ -264,7 +266,7 @@ TEST(SparseSet, Emplace) { ASSERT_DEATH(set.emplace(traits_type::combine(3, 1)), ""); ASSERT_DEATH(set.emplace(entities[1u]), ""); - + ASSERT_EQ(set.at(0u), entities[1u]); ASSERT_EQ(set.at(1u), entities[0u]); ASSERT_EQ(set.index(entities[0u]), 1u); @@ -283,7 +285,7 @@ TEST(SparseSet, Emplace) { TEST(SparseSet, EmplaceOutOfBounds) { entt::sparse_set set{entt::deletion_policy::in_place}; entt::entity entities[2u]{entt::entity{0}, entt::entity{ENTT_SPARSE_PAGE}}; - + set.emplace(entities[0u]); ASSERT_EQ(set.extent(), ENTT_SPARSE_PAGE); @@ -803,8 +805,8 @@ TEST(SparseSet, Iterator) { ASSERT_EQ(begin++, set.begin()); ASSERT_EQ(begin--, set.end()); - ASSERT_EQ(begin+1, set.end()); - ASSERT_EQ(end-1, set.begin()); + ASSERT_EQ(begin + 1, set.end()); + ASSERT_EQ(end - 1, set.begin()); ASSERT_EQ(++begin, set.end()); ASSERT_EQ(--begin, set.begin()); @@ -852,8 +854,8 @@ TEST(SparseSet, ReverseIterator) { ASSERT_EQ(begin++, set.rbegin()); ASSERT_EQ(begin--, set.rend()); - ASSERT_EQ(begin+1, set.rend()); - ASSERT_EQ(end-1, set.rbegin()); + ASSERT_EQ(begin + 1, set.rend()); + ASSERT_EQ(end - 1, set.rbegin()); ASSERT_EQ(++begin, set.rend()); ASSERT_EQ(--begin, set.rbegin()); diff --git a/test/entt/entity/storage.cpp b/test/entt/entity/storage.cpp index efcf9f17c..fe2f1e28c 100644 --- a/test/entt/entity/storage.cpp +++ b/test/entt/entity/storage.cpp @@ -1,9 +1,9 @@ -#include -#include -#include #include +#include +#include #include #include +#include #include #include #include @@ -12,14 +12,19 @@ struct empty_type {}; -struct boxed_int { int value; }; +struct boxed_int { + int value; +}; -struct stable_type { int value; }; +struct stable_type { + int value; +}; struct non_default_constructible { non_default_constructible() = delete; - non_default_constructible(int v): value{v} {} + non_default_constructible(int v) + : value{v} {} int value; }; @@ -27,15 +32,13 @@ struct non_default_constructible { struct update_from_destructor { update_from_destructor(entt::storage &ref, entt::entity other) : storage{&ref}, - target{other} - {} + target{other} {} update_from_destructor(update_from_destructor &&other) ENTT_NOEXCEPT : storage{std::exchange(other.storage, nullptr)}, - target{std::exchange(other.target, entt::null)} - {} + target{std::exchange(other.target, entt::null)} {} - update_from_destructor & operator=(update_from_destructor &&other) ENTT_NOEXCEPT { + update_from_destructor &operator=(update_from_destructor &&other) ENTT_NOEXCEPT { storage = std::exchange(other.storage, nullptr); target = std::exchange(other.target, entt::null); return *this; @@ -239,7 +242,7 @@ TEST(Storage, Insert) { ASSERT_EQ(pool.get(entities[1u]).value, 99); pool.erase(std::begin(entities), std::end(entities)); - const stable_type values[2u] = { stable_type{42}, stable_type{3} }; + const stable_type values[2u] = {stable_type{42}, stable_type{3}}; pool.insert(std::rbegin(entities), std::rend(entities), std::begin(values)); ASSERT_EQ(pool.size(), 2u); @@ -719,7 +722,9 @@ TEST(Storage, ShrinkToFit) { } TEST(Storage, AggregatesMustWork) { - struct aggregate_type { int value; }; + struct aggregate_type { + int value; + }; // the goal of this test is to enforce the requirements for aggregate types entt::storage{}.emplace(entt::entity{0}, 42); @@ -754,8 +759,8 @@ TEST(Storage, Iterator) { ASSERT_EQ(begin++, pool.begin()); ASSERT_EQ(begin--, pool.end()); - ASSERT_EQ(begin+1, pool.end()); - ASSERT_EQ(end-1, pool.begin()); + ASSERT_EQ(begin + 1, pool.end()); + ASSERT_EQ(end - 1, pool.begin()); ASSERT_EQ(++begin, pool.end()); ASSERT_EQ(--begin, pool.begin()); @@ -800,8 +805,8 @@ TEST(Storage, ConstIterator) { ASSERT_EQ(cbegin++, pool.cbegin()); ASSERT_EQ(cbegin--, pool.cend()); - ASSERT_EQ(cbegin+1, pool.cend()); - ASSERT_EQ(cend-1, pool.cbegin()); + ASSERT_EQ(cbegin + 1, pool.cend()); + ASSERT_EQ(cend - 1, pool.cbegin()); ASSERT_EQ(++cbegin, pool.cend()); ASSERT_EQ(--cbegin, pool.cbegin()); @@ -846,8 +851,8 @@ TEST(Storage, ReverseIterator) { ASSERT_EQ(begin++, pool.rbegin()); ASSERT_EQ(begin--, pool.rend()); - ASSERT_EQ(begin+1, pool.rend()); - ASSERT_EQ(end-1, pool.rbegin()); + ASSERT_EQ(begin + 1, pool.rend()); + ASSERT_EQ(end - 1, pool.rbegin()); ASSERT_EQ(++begin, pool.rend()); ASSERT_EQ(--begin, pool.rbegin()); @@ -892,8 +897,8 @@ TEST(Storage, ConstReverseIterator) { ASSERT_EQ(cbegin++, pool.crbegin()); ASSERT_EQ(cbegin--, pool.crend()); - ASSERT_EQ(cbegin+1, pool.crend()); - ASSERT_EQ(cend-1, pool.crbegin()); + ASSERT_EQ(cbegin + 1, pool.crend()); + ASSERT_EQ(cend - 1, pool.crbegin()); ASSERT_EQ(++cbegin, pool.crend()); ASSERT_EQ(--cbegin, pool.crbegin()); @@ -1230,13 +1235,13 @@ TEST(Storage, UpdateFromDestructor) { for(std::size_t next{}; next < size; ++next) { const auto entity = entt::entity(next); - pool.emplace(entity, pool, entity == entt::entity(size/2) ? target : entity); + pool.emplace(entity, pool, entity == entt::entity(size / 2) ? target : entity); } - pool.erase(entt::entity(size/2)); + pool.erase(entt::entity(size / 2)); ASSERT_EQ(pool.size(), size - 1u - (target != entt::null)); - ASSERT_FALSE(pool.contains(entt::entity(size/2))); + ASSERT_FALSE(pool.contains(entt::entity(size / 2))); ASSERT_FALSE(pool.contains(target)); pool.clear(); diff --git a/test/entt/entity/throwing_allocator.hpp b/test/entt/entity/throwing_allocator.hpp index 191d42291..96397ddf5 100644 --- a/test/entt/entity/throwing_allocator.hpp +++ b/test/entt/entity/throwing_allocator.hpp @@ -1,15 +1,12 @@ #ifndef ENTT_ENTITY_THROWING_ALLOCATOR_HPP #define ENTT_ENTITY_THROWING_ALLOCATOR_HPP - #include #include #include - namespace test { - template class throwing_allocator: std::allocator { template @@ -28,7 +25,8 @@ public: using propagate_on_container_swap = std::true_type; using exception_type = test_exception; - template struct rebind { + template + struct rebind { using other = throwing_allocator; }; @@ -36,8 +34,7 @@ public: template throwing_allocator(const throwing_allocator &other) - : base{other} - {} + : base{other} {} pointer allocate(std::size_t length) { if(trigger_on_allocate) { @@ -67,8 +64,6 @@ public: static inline bool trigger_after_allocate{}; }; - -} - +} // namespace test #endif diff --git a/test/entt/entity/throwing_component.hpp b/test/entt/entity/throwing_component.hpp index 878706c28..f7c8f4ecc 100644 --- a/test/entt/entity/throwing_component.hpp +++ b/test/entt/entity/throwing_component.hpp @@ -1,10 +1,8 @@ #ifndef ENTT_ENTITY_THROWING_COMPONENT_HPP #define ENTT_ENTITY_THROWING_COMPONENT_HPP - namespace test { - class throwing_component { struct test_exception {}; @@ -13,19 +11,17 @@ public: static constexpr auto moved_from_value = -1; throwing_component(int value) - : data{value} - {} + : data{value} {} throwing_component(const throwing_component &other) - : data{other.data} - { + : data{other.data} { if(data == trigger_on_value) { data = moved_from_value; throw exception_type{}; } } - throwing_component & operator=(const throwing_component &other) { + throwing_component &operator=(const throwing_component &other) { if(other.data == trigger_on_value) { data = moved_from_value; throw exception_type{}; @@ -45,8 +41,6 @@ private: int data{}; }; - -} - +} // namespace test #endif diff --git a/test/entt/entity/view.cpp b/test/entt/entity/view.cpp index c3e05df25..e849a7b29 100644 --- a/test/entt/entity/view.cpp +++ b/test/entt/entity/view.cpp @@ -1,7 +1,7 @@ #include #include -#include #include +#include #include #include #include @@ -9,7 +9,9 @@ struct empty_type {}; -struct stable_type { int value; }; +struct stable_type { + int value; +}; template<> struct entt::component_traits: basic_component_traits { @@ -236,14 +238,14 @@ TEST(SingleComponentView, ConstNonConstAndAllInBetween) { ASSERT_EQ(cview.size(), 1u); static_assert(std::is_same_v); - static_assert(std::is_same_v); + static_assert(std::is_same_v); static_assert(std::is_same_v({})), int &>); static_assert(std::is_same_v>); static_assert(std::is_same_v); static_assert(std::is_same_v({})), const int &>); static_assert(std::is_same_v>); - static_assert(std::is_same_v); + static_assert(std::is_same_v); static_assert(std::is_same_v()), decltype(cview)>); diff --git a/test/entt/locator/locator.cpp b/test/entt/locator/locator.cpp index 5f7874c71..4cd573fdd 100644 --- a/test/entt/locator/locator.cpp +++ b/test/entt/locator/locator.cpp @@ -10,9 +10,12 @@ struct another_service { }; struct derived_service: another_service { - derived_service(int): another_service{} {} + derived_service(int) + : another_service{} {} - void f(bool b) override { check = b; } + void f(bool b) override { + check = b; + } }; TEST(ServiceLocator, Functionalities) { diff --git a/test/entt/meta/meta_any.cpp b/test/entt/meta/meta_any.cpp index 7bd93e0a4..011983571 100644 --- a/test/entt/meta/meta_any.cpp +++ b/test/entt/meta/meta_any.cpp @@ -7,13 +7,20 @@ #include struct clazz_t { - clazz_t(): value{0} {} + clazz_t() + : value{0} {} - void member(int i) { value = i; } + void member(int i) { + value = i; + } - static void func() { c = 'd'; } + static void func() { + c = 'd'; + } - operator int() const { return value; } + operator int() const { + return value; + } static inline char c = 'c'; int value; @@ -34,12 +41,10 @@ struct empty_t { struct fat_t: empty_t { fat_t() - : value{.0, .0, .0, .0} - {} + : value{.0, .0, .0, .0} {} fat_t(double v1, double v2, double v3, double v4) - : value{v1, v2, v3, v4} - {} + : value{v1, v2, v3, v4} {} bool operator==(const fat_t &other) const { return std::equal(std::begin(value), std::end(value), std::begin(other.value), std::end(other.value)); @@ -48,7 +53,7 @@ struct fat_t: empty_t { double value[4]; }; -enum class enum_class: unsigned short int { +enum class enum_class : unsigned short int { foo = 0u, bar = 42u }; @@ -61,8 +66,8 @@ struct unmanageable_t { unmanageable_t() = default; unmanageable_t(const unmanageable_t &) = delete; unmanageable_t(unmanageable_t &&) = delete; - unmanageable_t & operator=(const unmanageable_t &) = delete; - unmanageable_t & operator=(unmanageable_t &&) = delete; + unmanageable_t &operator=(const unmanageable_t &) = delete; + unmanageable_t &operator=(unmanageable_t &&) = delete; }; struct MetaAny: ::testing::Test { @@ -525,7 +530,7 @@ TEST_F(MetaAny, SBODestruction) { } ASSERT_EQ(empty_t::destroy_counter, 3); - ASSERT_EQ(empty_t::destructor_counter,6); + ASSERT_EQ(empty_t::destructor_counter, 6); } TEST_F(MetaAny, NoSBODestruction) { diff --git a/test/entt/meta/meta_conv.cpp b/test/entt/meta/meta_conv.cpp index 85c1c9e8b..bd6e06009 100644 --- a/test/entt/meta/meta_conv.cpp +++ b/test/entt/meta/meta_conv.cpp @@ -8,7 +8,9 @@ struct clazz_t { clazz_t() = default; - operator int() const { return value; } + operator int() const { + return value; + } int value; }; diff --git a/test/entt/meta/meta_ctor.cpp b/test/entt/meta/meta_ctor.cpp index 7449c4434..ce34a1b42 100644 --- a/test/entt/meta/meta_ctor.cpp +++ b/test/entt/meta/meta_ctor.cpp @@ -7,39 +7,43 @@ #include struct base_t { - base_t(): value{'c'} {} + base_t() + : value{'c'} {} char value; }; struct derived_t: base_t { - derived_t(): base_t{} {} + derived_t() + : base_t{} {} }; struct clazz_t { clazz_t(const base_t &other, int &iv) - : clazz_t{iv, other.value} - {} + : clazz_t{iv, other.value} {} clazz_t(const int &iv, char cv) - : i{iv}, c{cv} - {} + : i{iv}, c{cv} {} - operator int() const { return i; } + operator int() const { + return i; + } static clazz_t factory(int value) { - return { value, 'c' }; + return {value, 'c'}; } static clazz_t factory(base_t other, int value, int mul) { - return { value * mul, other.value }; + return {value * mul, other.value}; } int i{}; char c{}; }; -double double_factory() { return 42.; } +double double_factory() { + return 42.; +} struct MetaCtor: ::testing::Test { void SetUp() override { diff --git a/test/entt/meta/meta_data.cpp b/test/entt/meta/meta_data.cpp index 4bc3ff167..c49e43902 100644 --- a/test/entt/meta/meta_data.cpp +++ b/test/entt/meta/meta_data.cpp @@ -25,10 +25,11 @@ struct clazz_t { clazz_t() : i{0}, j{1}, - base{} - {} + base{} {} - operator int() const { return h; } + operator int() const { + return h; + } int i{0}; const int j{1}; @@ -38,7 +39,8 @@ struct clazz_t { }; struct setter_getter_t { - setter_getter_t(): value{0} {} + setter_getter_t() + : value{0} {} int setter(double val) { return value = static_cast(val); @@ -52,7 +54,7 @@ struct setter_getter_t { return value = val; } - const int & getter_with_ref() { + const int &getter_with_ref() { return value; } @@ -68,7 +70,8 @@ struct setter_getter_t { }; struct multi_setter_t { - multi_setter_t(): value{0} {} + multi_setter_t() + : value{0} {} void from_double(double val) { value = val; @@ -110,11 +113,15 @@ struct MetaData: ::testing::Test { entt::meta() .type("clazz"_hs) - .data<&clazz_t::i, entt::as_ref_t>("i"_hs).prop(3, 0) + .data<&clazz_t::i, entt::as_ref_t>("i"_hs) + .prop(3, 0) .data<&clazz_t::i, entt::as_cref_t>("ci"_hs) - .data<&clazz_t::j>("j"_hs).prop(true, 1) - .data<&clazz_t::h>("h"_hs).prop(property_t::random, 2) - .data<&clazz_t::k>("k"_hs).prop(property_t::value, 3) + .data<&clazz_t::j>("j"_hs) + .prop(true, 1) + .data<&clazz_t::h>("h"_hs) + .prop(property_t::random, 2) + .data<&clazz_t::k>("k"_hs) + .prop(property_t::value, 3) .data<&clazz_t::base>("base"_hs) .data<&clazz_t::i, entt::as_void_t>("void"_hs) .conv(); diff --git a/test/entt/meta/meta_func.cpp b/test/entt/meta/meta_func.cpp index ed1fffd3f..7d67e11bd 100644 --- a/test/entt/meta/meta_func.cpp +++ b/test/entt/meta/meta_func.cpp @@ -22,7 +22,8 @@ struct base_t { }; struct derived_t: base_t { - derived_t(): base_t{} {} + derived_t() + : base_t{} {} }; struct func_t { @@ -32,15 +33,15 @@ struct func_t { int f(int a, int b) { value = a; - return b*b; + return b * b; } int f(int v) const { - return v*v; + return v * v; } void g(int v) { - value = v*v; + value = v * v; } static int h(int &v) { @@ -55,7 +56,7 @@ struct func_t { return (value = v); } - int & a() const { + int &a() const { return value; } @@ -87,11 +88,16 @@ struct MetaFunc: ::testing::Test { .type("func"_hs) .func<&entt::registry::emplace_or_replace, entt::as_ref_t>("emplace"_hs) .func(&func_t::f)>("f3"_hs) - .func(&func_t::f)>("f2"_hs).prop(true, false) - .func(&func_t::f)>("f1"_hs).prop(true, false) - .func<&func_t::g>("g"_hs).prop(true, false) - .func("h"_hs).prop(true, false) - .func("k"_hs).prop(true, false) + .func(&func_t::f)>("f2"_hs) + .prop(true, false) + .func(&func_t::f)>("f1"_hs) + .prop(true, false) + .func<&func_t::g>("g"_hs) + .prop(true, false) + .func("h"_hs) + .prop(true, false) + .func("k"_hs) + .prop(true, false) .func<&func_t::v, entt::as_void_t>("v"_hs) .func<&func_t::a, entt::as_ref_t>("a"_hs) .func<&func_t::a, entt::as_cref_t>("ca"_hs) diff --git a/test/entt/meta/meta_handle.cpp b/test/entt/meta/meta_handle.cpp index 08637bf78..ff83ae067 100644 --- a/test/entt/meta/meta_handle.cpp +++ b/test/entt/meta/meta_handle.cpp @@ -5,11 +5,16 @@ #include struct clazz_t { - clazz_t(): value{} {} + clazz_t() + : value{} {} - void incr() { ++value; } + void incr() { + ++value; + } - void decr() { --value; } + void decr() { + --value; + } int value; }; diff --git a/test/entt/meta/meta_pointer.cpp b/test/entt/meta/meta_pointer.cpp index 54757638d..ade4157dc 100644 --- a/test/entt/meta/meta_pointer.cpp +++ b/test/entt/meta/meta_pointer.cpp @@ -8,9 +8,12 @@ template struct wrapped_shared_ptr { - wrapped_shared_ptr(Type init): ptr{new Type {init}} {} + wrapped_shared_ptr(Type init) + : ptr{new Type{init}} {} - Type & deref() const { return *ptr; } + Type &deref() const { + return *ptr; + } private: std::shared_ptr ptr; @@ -19,9 +22,12 @@ private: struct self_ptr { using element_type = self_ptr; - self_ptr(int v): value{v} {} + self_ptr(int v) + : value{v} {} - const self_ptr & operator*() const { return *this; } + const self_ptr &operator*() const { + return *this; + } int value; }; @@ -29,9 +35,12 @@ struct self_ptr { struct proxy_ptr { using element_type = proxy_ptr; - proxy_ptr(int &v): value{&v} {} + proxy_ptr(int &v) + : value{&v} {} - proxy_ptr operator*() const { return *this; } + proxy_ptr operator*() const { + return *this; + } int *value; }; @@ -62,18 +71,20 @@ struct entt::adl_meta_pointer_like> { }; template -Type & dereference_meta_pointer_like(const adl_wrapped_shared_ptr &ptr) { +Type &dereference_meta_pointer_like(const adl_wrapped_shared_ptr &ptr) { return ptr.deref(); } -int test_function() { return 42; } +int test_function() { + return 42; +} struct not_copyable_t { not_copyable_t() = default; not_copyable_t(const not_copyable_t &) = delete; not_copyable_t(not_copyable_t &&) = default; - not_copyable_t & operator=(const not_copyable_t &) = delete; - not_copyable_t & operator=(not_copyable_t &&) = default; + not_copyable_t &operator=(const not_copyable_t &) = delete; + not_copyable_t &operator=(not_copyable_t &&) = default; }; TEST(MetaPointerLike, DereferenceOperatorInvalidType) { @@ -199,7 +210,7 @@ TEST(MetaPointerLike, PointerToConstMoveOnlyType) { TEST(MetaPointerLike, AsRef) { int value = 0; - int * ptr = &value; + int *ptr = &value; entt::meta_any any{entt::forward_as_meta(ptr)}; ASSERT_TRUE(any.type().is_pointer()); @@ -221,7 +232,7 @@ TEST(MetaPointerLike, AsRef) { TEST(MetaPointerLike, AsConstRef) { int value = 42; - int * const ptr = &value; + int *const ptr = &value; entt::meta_any any{entt::forward_as_meta(ptr)}; ASSERT_TRUE(any.type().is_pointer()); @@ -307,15 +318,15 @@ TEST(MetaPointerLike, DereferenceSmartPointerToVoid) { }; test(std::shared_ptr{}); - test(std::unique_ptr{nullptr, nullptr}); + test(std::unique_ptr{nullptr, nullptr}); } TEST(MetaPointerLike, DereferencePointerToFunction) { auto test = [](entt::meta_any any) { ASSERT_TRUE(any.type().is_pointer()); ASSERT_TRUE(any.type().is_pointer_like()); - ASSERT_NE(any.try_cast(), nullptr); - ASSERT_EQ(any.cast()(), 42); + ASSERT_NE(any.try_cast(), nullptr); + ASSERT_EQ(any.cast()(), 42); }; entt::meta_any func{&test_function}; diff --git a/test/entt/meta/meta_type.cpp b/test/entt/meta/meta_type.cpp index 1d94788bc..90b2d09ff 100644 --- a/test/entt/meta/meta_type.cpp +++ b/test/entt/meta/meta_type.cpp @@ -22,13 +22,15 @@ Type get(Type &prop) { } struct base_t { - base_t(): value{'c'} {}; + base_t() + : value{'c'} {}; char value; }; struct derived_t: base_t { - derived_t(): base_t{} {} + derived_t() + : base_t{} {} }; struct abstract_t { @@ -50,13 +52,14 @@ struct clazz_t { clazz_t() = default; clazz_t(const base_t &, int v) - : value{v} - {} + : value{v} {} void member() {} static void func() {} - operator int() const { return value; } + operator int() const { + return value; + } int value; }; @@ -130,28 +133,28 @@ struct MetaType: ::testing::Test { entt::meta() .type("overloaded_func"_hs) - .func<&overloaded_func_t::e> ("e"_hs) + .func<&overloaded_func_t::e>("e"_hs) .func(&overloaded_func_t::f)>("f"_hs) .func(&overloaded_func_t::f)>("f"_hs) .func(&overloaded_func_t::f)>("f"_hs) - .func (&overloaded_func_t::f)> ("f"_hs) - .func<&overloaded_func_t::g> ("g"_hs); + .func(&overloaded_func_t::f)>("f"_hs) + .func<&overloaded_func_t::g>("g"_hs); entt::meta() .type("property"_hs) .data("random"_hs) - .props(std::make_pair(property_t::random, 0), std::make_pair(property_t::value, 3)) + .props(std::make_pair(property_t::random, 0), std::make_pair(property_t::value, 3)) .data("value"_hs) - .props(std::make_pair(property_t::random, true), std::make_pair(property_t::value, 0), property_t::key_only, property_t::list) + .props(std::make_pair(property_t::random, true), std::make_pair(property_t::value, 0), property_t::key_only, property_t::list) .data("key_only"_hs) - .prop(property_t::key_only) + .prop(property_t::key_only) .data("list"_hs) - .props(std::make_pair(property_t::random, false), std::make_pair(property_t::value, 0), property_t::key_only) + .props(std::make_pair(property_t::random, false), std::make_pair(property_t::value, 0), property_t::key_only) .data, get>("var"_hs); entt::meta() .type("clazz"_hs) - .prop(property_t::value, 42) + .prop(property_t::value, 42) .ctor() .data<&clazz_t::value>("value"_hs) .func<&clazz_t::member>("member"_hs) @@ -606,7 +609,7 @@ TEST_F(MetaType, ResetAndReRegistrationAfterReset) { entt::meta() .type("property"_hs) .data("rand"_hs) - .props(std::make_pair(property_t::value, 42), std::make_pair(property_t::random, 3)); + .props(std::make_pair(property_t::value, 42), std::make_pair(property_t::random, 3)); ASSERT_TRUE(entt::resolve().data("rand"_hs).prop(property_t::value)); ASSERT_TRUE(entt::resolve().data("rand"_hs).prop(property_t::random)); diff --git a/test/entt/poly/poly_deduced.cpp b/test/entt/poly/poly_deduced.cpp index 718603770..33924838d 100644 --- a/test/entt/poly/poly_deduced.cpp +++ b/test/entt/poly/poly_deduced.cpp @@ -5,26 +5,39 @@ #include struct Deduced - : entt::type_list<> -{ + : entt::type_list<> { template struct type: Base { - void incr() { entt::poly_call<0>(*this); } + void incr() { + entt::poly_call<0>(*this); + } - void set(int v) { entt::poly_call<1>(*this, v); } + void set(int v) { + entt::poly_call<1>(*this, v); + } - int get() const { return entt::poly_call<2>(*this); } + int get() const { + return entt::poly_call<2>(*this); + } - void decr() { entt::poly_call<3>(*this); } + void decr() { + entt::poly_call<3>(*this); + } - int mul(int v) const { return static_cast(entt::poly_call<4>(*this, v)); } + int mul(int v) const { + return static_cast(entt::poly_call<4>(*this, v)); + } }; template struct members { - static void decr(Type &self) { self.set(self.get()-1); } + static void decr(Type &self) { + self.set(self.get() - 1); + } - static double mul(const Type &self, double v) { return v * self.get(); } + static double mul(const Type &self, double v) { + return v * self.get(); + } }; template @@ -33,24 +46,34 @@ struct Deduced &Type::set, &Type::get, &members::decr, - &members::mul - >; + &members::mul>; }; struct impl { impl() = default; - impl(int v): value{v} {} + impl(int v) + : value{v} {} - void incr() { ++value; } + void incr() { + ++value; + } - void set(int v) { value = v; } + void set(int v) { + value = v; + } - int get() const { return value; } + int get() const { + return value; + } - void decrement() { --value; } + void decrement() { + --value; + } - double multiply(double v) const { return v * value; } + double multiply(double v) const { + return v * value; + } int value{}; }; @@ -261,9 +284,9 @@ TEST(PolyDeduced, Alignment) { cb(data, target[1].data()); }; - entt::basic_poly nosbo[2] = { over_aligned{}, over_aligned{} }; + entt::basic_poly nosbo[2] = {over_aligned{}, over_aligned{}}; test(nosbo, [](auto *pre, auto *post) { ASSERT_EQ(pre, post); }); - entt::basic_poly sbo[2] = { over_aligned{}, over_aligned{} }; + entt::basic_poly sbo[2] = {over_aligned{}, over_aligned{}}; test(sbo, [](auto *pre, auto *post) { ASSERT_NE(pre, post); }); } diff --git a/test/entt/poly/poly_defined.cpp b/test/entt/poly/poly_defined.cpp index de502a796..b96dcb7ab 100644 --- a/test/entt/poly/poly_defined.cpp +++ b/test/entt/poly/poly_defined.cpp @@ -6,31 +6,43 @@ struct Defined : entt::type_list< - void(), - void(int), - int() const, - void(), - int(int) const - > -{ + void(), + void(int), + int() const, + void(), + int(int) const> { template struct type: Base { - void incr() { entt::poly_call<0>(*this); } + void incr() { + entt::poly_call<0>(*this); + } - void set(int v) { entt::poly_call<1>(*this, v); } + void set(int v) { + entt::poly_call<1>(*this, v); + } - int get() const { return entt::poly_call<2>(*this); } + int get() const { + return entt::poly_call<2>(*this); + } - void decr() { entt::poly_call<3>(*this); } + void decr() { + entt::poly_call<3>(*this); + } - int mul(int v) const { return entt::poly_call<4>(*this, v); } + int mul(int v) const { + return entt::poly_call<4>(*this, v); + } }; template struct members { - static void decr(Type &self) { self.decrement(); } + static void decr(Type &self) { + self.decrement(); + } - static double mul(const Type &self, double v) { return self.multiply(v); } + static double mul(const Type &self, double v) { + return self.multiply(v); + } }; template @@ -39,24 +51,34 @@ struct Defined &Type::set, &Type::get, &members::decr, - &members::mul - >; + &members::mul>; }; struct impl { impl() = default; - impl(int v): value{v} {} + impl(int v) + : value{v} {} - void incr() { ++value; } + void incr() { + ++value; + } - void set(int v) { value = v; } + void set(int v) { + value = v; + } - int get() const { return value; } + int get() const { + return value; + } - void decrement() { --value; } + void decrement() { + --value; + } - double multiply(double v) const { return v * value; } + double multiply(double v) const { + return v * value; + } int value{}; }; @@ -267,9 +289,9 @@ TEST(PolyDefined, Alignment) { cb(data, target[1].data()); }; - entt::basic_poly nosbo[2] = { over_aligned{}, over_aligned{} }; + entt::basic_poly nosbo[2] = {over_aligned{}, over_aligned{}}; test(nosbo, [](auto *pre, auto *post) { ASSERT_EQ(pre, post); }); - entt::basic_poly sbo[2] = { over_aligned{}, over_aligned{} }; + entt::basic_poly sbo[2] = {over_aligned{}, over_aligned{}}; test(sbo, [](auto *pre, auto *post) { ASSERT_NE(pre, post); }); } diff --git a/test/entt/process/process.cpp b/test/entt/process/process.cpp index 38323456f..4c5c6575b 100644 --- a/test/entt/process/process.cpp +++ b/test/entt/process/process.cpp @@ -14,24 +14,39 @@ struct fake_process: entt::process, Delta> { update_invoked{false}, succeeded_invoked{false}, failed_invoked{false}, - aborted_invoked{false} - {} + aborted_invoked{false} {} - void succeed() noexcept { process_type::succeed(); } + void succeed() noexcept { + process_type::succeed(); + } - void fail() noexcept { process_type::fail(); } + void fail() noexcept { + process_type::fail(); + } - void pause() noexcept { process_type::pause(); } + void pause() noexcept { + process_type::pause(); + } - void unpause() noexcept { process_type::unpause(); } + void unpause() noexcept { + process_type::unpause(); + } - void init() { init_invoked = true; } + void init() { + init_invoked = true; + } - void succeeded() { succeeded_invoked = true; } + void succeeded() { + succeeded_invoked = true; + } - void failed() { failed_invoked = true; } + void failed() { + failed_invoked = true; + } - void aborted() { aborted_invoked = true; } + void aborted() { + aborted_invoked = true; + } void update(typename entt::process, Delta>::delta_type, void *data) { if(data) { diff --git a/test/entt/process/scheduler.cpp b/test/entt/process/scheduler.cpp index 2adb604b2..f8bbfb4a9 100644 --- a/test/entt/process/scheduler.cpp +++ b/test/entt/process/scheduler.cpp @@ -1,16 +1,19 @@ #include #include -#include #include +#include struct foo_process: entt::process { foo_process(std::function upd, std::function abort) - : on_update{upd}, on_aborted{abort} - {} + : on_update{upd}, on_aborted{abort} {} - void update(delta_type, void *) { on_update(); } + void update(delta_type, void *) { + on_update(); + } - void aborted() { on_aborted(); } + void aborted() { + on_aborted(); + } std::function on_update; std::function on_aborted; @@ -50,9 +53,8 @@ TEST(Scheduler, Functionalities) { ASSERT_TRUE(scheduler.empty()); scheduler.attach( - [&updated](){ updated = true; }, - [&aborted](){ aborted = true; } - ); + [&updated]() { updated = true; }, + [&aborted]() { aborted = true; }); ASSERT_NE(scheduler.size(), 0u); ASSERT_FALSE(scheduler.empty()); diff --git a/test/entt/resource/resource.cpp b/test/entt/resource/resource.cpp index 4e250919f..ed2561c47 100644 --- a/test/entt/resource/resource.cpp +++ b/test/entt/resource/resource.cpp @@ -3,7 +3,9 @@ #include #include -struct resource { int value; }; +struct resource { + int value; +}; struct derived_resource: resource {}; diff --git a/test/entt/signal/delegate.cpp b/test/entt/signal/delegate.cpp index f1685265a..59391eead 100644 --- a/test/entt/signal/delegate.cpp +++ b/test/entt/signal/delegate.cpp @@ -3,15 +3,15 @@ #include int delegate_function(const int &i) { - return i*i; + return i * i; } int curried_by_ref(const int &i, int j) { - return i+j; + return i + j; } int curried_by_ptr(const int *i, int j) { - return (*i)*j; + return (*i) * j; } int non_const_reference(int &i) { @@ -24,7 +24,7 @@ int move_only_type(std::unique_ptr ptr) { struct delegate_functor { int operator()(int i) { - return i+i; + return i + i; } int identity(int i) const { @@ -36,13 +36,21 @@ struct delegate_functor { }; struct const_nonconst_noexcept { - void f() { ++cnt; } + void f() { + ++cnt; + } - void g() noexcept { ++cnt; } + void g() noexcept { + ++cnt; + } - void h() const { ++cnt; } + void h() const { + ++cnt; + } - void i() const noexcept { ++cnt; } + void i() const noexcept { + ++cnt; + } int u{}; const int v{}; diff --git a/test/entt/signal/dispatcher.cpp b/test/entt/signal/dispatcher.cpp index db96a4cec..b1a8a5bfe 100644 --- a/test/entt/signal/dispatcher.cpp +++ b/test/entt/signal/dispatcher.cpp @@ -7,16 +7,22 @@ struct an_event {}; struct another_event {}; // makes the type non-aggregate -struct one_more_event { one_more_event(int) {} }; +struct one_more_event { + one_more_event(int) {} +}; struct receiver { static void forward(entt::dispatcher &dispatcher, an_event &event) { dispatcher.enqueue(event); } - void receive(const an_event &) { ++cnt; } + void receive(const an_event &) { + ++cnt; + } - void reset() { cnt = 0; } + void reset() { + cnt = 0; + } int cnt{0}; }; diff --git a/test/entt/signal/emitter.cpp b/test/entt/signal/emitter.cpp index b146964ef..3fed8a67a 100644 --- a/test/entt/signal/emitter.cpp +++ b/test/entt/signal/emitter.cpp @@ -4,7 +4,10 @@ struct test_emitter: entt::emitter {}; -struct foo_event { int i; char c; }; +struct foo_event { + int i; + char c; +}; struct bar_event {}; struct quux_event {}; @@ -14,8 +17,8 @@ TEST(Emitter, Clear) { ASSERT_TRUE(emitter.empty()); - emitter.on([](auto &, const auto &){}); - emitter.once([](const auto &, const auto &){}); + emitter.on([](auto &, const auto &) {}); + emitter.once([](const auto &, const auto &) {}); ASSERT_FALSE(emitter.empty()); ASSERT_FALSE(emitter.empty()); @@ -36,8 +39,8 @@ TEST(Emitter, Clear) { ASSERT_FALSE(emitter.empty()); ASSERT_TRUE(emitter.empty()); - emitter.on([](auto &, const auto &){}); - emitter.on([](const auto &, const auto &){}); + emitter.on([](auto &, const auto &) {}); + emitter.on([](const auto &, const auto &) {}); ASSERT_FALSE(emitter.empty()); ASSERT_FALSE(emitter.empty()); @@ -56,13 +59,13 @@ TEST(Emitter, ClearPublishing) { ASSERT_TRUE(emitter.empty()); - emitter.once([](auto &, auto &em){ - em.template once([](auto &, auto &){}); + emitter.once([](auto &, auto &em) { + em.template once([](auto &, auto &) {}); em.template clear(); }); - emitter.on([](const auto &, auto &em){ - em.template once([](const auto &, auto &){}); + emitter.on([](const auto &, auto &em) { + em.template once([](const auto &, auto &) {}); em.template clear(); }); @@ -77,7 +80,7 @@ TEST(Emitter, ClearPublishing) { TEST(Emitter, On) { test_emitter emitter; - emitter.on([](auto &, const auto &){}); + emitter.on([](auto &, const auto &) {}); ASSERT_FALSE(emitter.empty()); ASSERT_FALSE(emitter.empty()); @@ -91,7 +94,7 @@ TEST(Emitter, On) { TEST(Emitter, Once) { test_emitter emitter; - emitter.once([](const auto &, const auto &){}); + emitter.once([](const auto &, const auto &) {}); ASSERT_FALSE(emitter.empty()); ASSERT_FALSE(emitter.empty()); @@ -105,7 +108,7 @@ TEST(Emitter, Once) { TEST(Emitter, OnceAndErase) { test_emitter emitter; - auto conn = emitter.once([](auto &, const auto &){}); + auto conn = emitter.once([](auto &, const auto &) {}); ASSERT_FALSE(emitter.empty()); ASSERT_FALSE(emitter.empty()); @@ -119,7 +122,7 @@ TEST(Emitter, OnceAndErase) { TEST(Emitter, OnAndErase) { test_emitter emitter; - auto conn = emitter.on([](const auto &, const auto &){}); + auto conn = emitter.on([](const auto &, const auto &) {}); ASSERT_FALSE(emitter.empty()); ASSERT_FALSE(emitter.empty()); diff --git a/test/entt/signal/sigh.cpp b/test/entt/signal/sigh.cpp index dafd53cfc..7082aca5a 100644 --- a/test/entt/signal/sigh.cpp +++ b/test/entt/signal/sigh.cpp @@ -4,28 +4,45 @@ #include struct sigh_listener { - static void f(int &v) { v = 42; } + static void f(int &v) { + v = 42; + } - bool g(int) { k = !k; return true; } + bool g(int) { + k = !k; + return true; + } - bool h(const int &) { return k; } + bool h(const int &) { + return k; + } void i() {} // useless definition just because msvc does weird things if both are empty - void l() { k = true && k; } + void l() { + k = true && k; + } bool k{false}; }; struct before_after { - void add(int v) { value += v; } + void add(int v) { + value += v; + } - void mul(int v) { value *= v; } + void mul(int v) { + value *= v; + } - static void static_add(int v) { before_after::value += v; } + static void static_add(int v) { + before_after::value += v; + } - static void static_mul(before_after &instance, int v) { instance.value *= v; } + static void static_mul(before_after &instance, int v) { + instance.value *= v; + } static inline int value{}; }; @@ -37,13 +54,21 @@ struct SigH: ::testing::Test { }; struct const_nonconst_noexcept { - void f() { ++cnt; } + void f() { + ++cnt; + } - void g() noexcept { ++cnt; } + void g() noexcept { + ++cnt; + } - void h() const { ++cnt; } + void h() const { + ++cnt; + } - void i() const noexcept { ++cnt; } + void i() const noexcept { + ++cnt; + } mutable int cnt{0}; }; diff --git a/test/example/custom_identifier.cpp b/test/example/custom_identifier.cpp index 3a8e57ca5..188803ec9 100644 --- a/test/example/custom_identifier.cpp +++ b/test/example/custom_identifier.cpp @@ -8,12 +8,10 @@ struct entity_id { static constexpr auto null = entt::null; constexpr entity_id(entity_type value = null) ENTT_NOEXCEPT - : entt{value} - {} + : entt{value} {} constexpr entity_id(const entity_id &other) ENTT_NOEXCEPT - : entt{other.entt} - {} + : entt{other.entt} {} constexpr operator entity_type() const ENTT_NOEXCEPT { return entt; diff --git a/test/lib/dispatcher/main.cpp b/test/lib/dispatcher/main.cpp index 866ed1439..d6aa70fc1 100644 --- a/test/lib/dispatcher/main.cpp +++ b/test/lib/dispatcher/main.cpp @@ -7,7 +7,9 @@ ENTT_API void trigger(entt::dispatcher &); struct listener { - void on(message msg) { value = msg.payload; } + void on(message msg) { + value = msg.payload; + } int value{}; }; diff --git a/test/lib/dispatcher_plugin/main.cpp b/test/lib/dispatcher_plugin/main.cpp index 9e4a9b800..2ff0a8995 100644 --- a/test/lib/dispatcher_plugin/main.cpp +++ b/test/lib/dispatcher_plugin/main.cpp @@ -1,7 +1,7 @@ #define CR_HOST -#include #include +#include #include #include #include "type_context.h" @@ -16,7 +16,10 @@ struct entt::type_index { }; struct listener { - void on(message msg) { value = msg.payload; } + void on(message msg) { + value = msg.payload; + } + int value{}; }; diff --git a/test/lib/dispatcher_plugin/plugin.cpp b/test/lib/dispatcher_plugin/plugin.cpp index d55537fcc..ca0ca5d64 100644 --- a/test/lib/dispatcher_plugin/plugin.cpp +++ b/test/lib/dispatcher_plugin/plugin.cpp @@ -17,7 +17,7 @@ struct entt::type_index { }; CR_EXPORT int cr_main(cr_plugin *ctx, cr_op operation) { - switch (operation) { + switch(operation) { case CR_STEP: if(!ctx::ref) { ctx::ref = static_cast(ctx->userdata); diff --git a/test/lib/dispatcher_plugin/type_context.h b/test/lib/dispatcher_plugin/type_context.h index 4a038b03c..ceb1aa634 100644 --- a/test/lib/dispatcher_plugin/type_context.h +++ b/test/lib/dispatcher_plugin/type_context.h @@ -16,7 +16,7 @@ public: return name_to_index[name]; } - static type_context * instance() { + static type_context *instance() { static type_context self{}; return &self; } diff --git a/test/lib/emitter/types.h b/test/lib/emitter/types.h index 647d51f0b..ec2c133bf 100644 --- a/test/lib/emitter/types.h +++ b/test/lib/emitter/types.h @@ -5,8 +5,7 @@ #include struct ENTT_API test_emitter - : entt::emitter -{}; + : entt::emitter {}; struct ENTT_API message { int payload; diff --git a/test/lib/emitter_plugin/main.cpp b/test/lib/emitter_plugin/main.cpp index 623f848eb..51b81c42b 100644 --- a/test/lib/emitter_plugin/main.cpp +++ b/test/lib/emitter_plugin/main.cpp @@ -1,7 +1,7 @@ #define CR_HOST -#include #include +#include #include #include #include "type_context.h" diff --git a/test/lib/emitter_plugin/plugin.cpp b/test/lib/emitter_plugin/plugin.cpp index 0e08cea9c..b13065e1d 100644 --- a/test/lib/emitter_plugin/plugin.cpp +++ b/test/lib/emitter_plugin/plugin.cpp @@ -17,7 +17,7 @@ struct entt::type_index { }; CR_EXPORT int cr_main(cr_plugin *ctx, cr_op operation) { - switch (operation) { + switch(operation) { case CR_STEP: if(!ctx::ref) { ctx::ref = static_cast(ctx->userdata); diff --git a/test/lib/emitter_plugin/type_context.h b/test/lib/emitter_plugin/type_context.h index f9b9f0aa8..1e4e97c4c 100644 --- a/test/lib/emitter_plugin/type_context.h +++ b/test/lib/emitter_plugin/type_context.h @@ -16,7 +16,7 @@ public: return name_to_index[name]; } - static type_context * instance() { + static type_context *instance() { static type_context self{}; return &self; } diff --git a/test/lib/emitter_plugin/types.h b/test/lib/emitter_plugin/types.h index 41cef4dab..a4c78244f 100644 --- a/test/lib/emitter_plugin/types.h +++ b/test/lib/emitter_plugin/types.h @@ -4,8 +4,7 @@ #include struct test_emitter - : entt::emitter -{}; + : entt::emitter {}; struct message { int payload; diff --git a/test/lib/meta/lib.cpp b/test/lib/meta/lib.cpp index be4ff650b..b5b27efd7 100644 --- a/test/lib/meta/lib.cpp +++ b/test/lib/meta/lib.cpp @@ -13,16 +13,16 @@ ENTT_API void set_up() { using namespace entt::literals; entt::meta() - .type("position"_hs) - .ctor<&create_position>() - .data<&position::x>("x"_hs) - .data<&position::y>("y"_hs); + .type("position"_hs) + .ctor<&create_position>() + .data<&position::x>("x"_hs) + .data<&position::y>("y"_hs); entt::meta() - .type("velocity"_hs) - .ctor<>() - .data<&velocity::dx>("dx"_hs) - .data<&velocity::dy>("dy"_hs); + .type("velocity"_hs) + .ctor<>() + .data<&velocity::dx>("dx"_hs) + .data<&velocity::dy>("dy"_hs); } ENTT_API void tear_down() { diff --git a/test/lib/meta_plugin/main.cpp b/test/lib/meta_plugin/main.cpp index 2c1b99489..ab4d73205 100644 --- a/test/lib/meta_plugin/main.cpp +++ b/test/lib/meta_plugin/main.cpp @@ -1,7 +1,7 @@ #define CR_HOST -#include #include +#include #include #include #include diff --git a/test/lib/meta_plugin/plugin.cpp b/test/lib/meta_plugin/plugin.cpp index d8b784b85..43b115e48 100644 --- a/test/lib/meta_plugin/plugin.cpp +++ b/test/lib/meta_plugin/plugin.cpp @@ -13,16 +13,16 @@ void set_up() { using namespace entt::literals; entt::meta() - .type("position"_hs) - .ctor<&create_position>() - .data<&position::x>("x"_hs) - .data<&position::y>("y"_hs); + .type("position"_hs) + .ctor<&create_position>() + .data<&position::x>("x"_hs) + .data<&position::y>("y"_hs); entt::meta() - .type("velocity"_hs) - .ctor<>() - .data<&velocity::dx>("dx"_hs) - .data<&velocity::dy>("dy"_hs); + .type("velocity"_hs) + .ctor<>() + .data<&velocity::dx>("dx"_hs) + .data<&velocity::dy>("dy"_hs); } void tear_down() { @@ -31,7 +31,7 @@ void tear_down() { } CR_EXPORT int cr_main(cr_plugin *ctx, cr_op operation) { - switch (operation) { + switch(operation) { case CR_LOAD: entt::meta_ctx::bind(static_cast(ctx->userdata)->ctx); set_up(); diff --git a/test/lib/meta_plugin_std/main.cpp b/test/lib/meta_plugin_std/main.cpp index 2c1b99489..ab4d73205 100644 --- a/test/lib/meta_plugin_std/main.cpp +++ b/test/lib/meta_plugin_std/main.cpp @@ -1,7 +1,7 @@ #define CR_HOST -#include #include +#include #include #include #include diff --git a/test/lib/meta_plugin_std/plugin.cpp b/test/lib/meta_plugin_std/plugin.cpp index d8b784b85..43b115e48 100644 --- a/test/lib/meta_plugin_std/plugin.cpp +++ b/test/lib/meta_plugin_std/plugin.cpp @@ -13,16 +13,16 @@ void set_up() { using namespace entt::literals; entt::meta() - .type("position"_hs) - .ctor<&create_position>() - .data<&position::x>("x"_hs) - .data<&position::y>("y"_hs); + .type("position"_hs) + .ctor<&create_position>() + .data<&position::x>("x"_hs) + .data<&position::y>("y"_hs); entt::meta() - .type("velocity"_hs) - .ctor<>() - .data<&velocity::dx>("dx"_hs) - .data<&velocity::dy>("dy"_hs); + .type("velocity"_hs) + .ctor<>() + .data<&velocity::dx>("dx"_hs) + .data<&velocity::dy>("dy"_hs); } void tear_down() { @@ -31,7 +31,7 @@ void tear_down() { } CR_EXPORT int cr_main(cr_plugin *ctx, cr_op operation) { - switch (operation) { + switch(operation) { case CR_LOAD: entt::meta_ctx::bind(static_cast(ctx->userdata)->ctx); set_up(); diff --git a/test/lib/meta_plugin_std/types.h b/test/lib/meta_plugin_std/types.h index 426321d4f..feafe93b1 100644 --- a/test/lib/meta_plugin_std/types.h +++ b/test/lib/meta_plugin_std/types.h @@ -9,11 +9,10 @@ template struct custom_type_hash; -#define ASSIGN_TYPE_ID(clazz)\ - template<>\ - struct custom_type_hash\ - : std::integral_constant>>>{#clazz}>\ - {} +#define ASSIGN_TYPE_ID(clazz) \ + template<> \ + struct custom_type_hash \ + : std::integral_constant>>>{#clazz}> {} template struct entt::type_hash { diff --git a/test/lib/registry_plugin/main.cpp b/test/lib/registry_plugin/main.cpp index 5450913f4..3a034f0f3 100644 --- a/test/lib/registry_plugin/main.cpp +++ b/test/lib/registry_plugin/main.cpp @@ -1,7 +1,7 @@ #define CR_HOST -#include #include +#include #include #include #include "type_context.h" diff --git a/test/lib/registry_plugin/plugin.cpp b/test/lib/registry_plugin/plugin.cpp index 8a00fccf4..b429c816e 100644 --- a/test/lib/registry_plugin/plugin.cpp +++ b/test/lib/registry_plugin/plugin.cpp @@ -17,7 +17,7 @@ struct entt::type_index { }; CR_EXPORT int cr_main(cr_plugin *ctx, cr_op operation) { - switch (operation) { + switch(operation) { case CR_STEP: if(!ctx::ref) { ctx::ref = static_cast(ctx->userdata); diff --git a/test/lib/registry_plugin/type_context.h b/test/lib/registry_plugin/type_context.h index 042f5bd40..e0c90f0e2 100644 --- a/test/lib/registry_plugin/type_context.h +++ b/test/lib/registry_plugin/type_context.h @@ -16,7 +16,7 @@ public: return name_to_index[name]; } - static type_context * instance() { + static type_context *instance() { static type_context self{}; return &self; } diff --git a/test/snapshot/snapshot.cpp b/test/snapshot/snapshot.cpp index 40a3ae2ec..177d6d60a 100644 --- a/test/snapshot/snapshot.cpp +++ b/test/snapshot/snapshot.cpp @@ -1,10 +1,10 @@ -#include #include #include +#include #include +#include #include #include -#include struct position { float x; @@ -135,8 +135,8 @@ TEST(Snapshot, Continuous) { cereal::JSONInputArchive input{storage}; entt::continuous_loader loader{destination}; loader.entities(input) - .component(input, &relationship::parent) - .component>(input); + .component(input, &relationship::parent) + .component>(input); ASSERT_FALSE(destination.valid(e0)); ASSERT_TRUE(loader.contains(e0));