From 13d901fbfa0cded223c82d4e6452ca7a7d9bb81a Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Fri, 17 Sep 2021 16:43:15 +0200 Subject: [PATCH] *: a handful of changes to please clang-format --- src/entt/core/any.hpp | 9 ++++-- src/entt/core/compressed_pair.hpp | 12 +++----- src/entt/core/hashed_string.hpp | 3 +- src/entt/core/type_traits.hpp | 13 +++------ src/entt/core/utility.hpp | 3 +- src/entt/entity/group.hpp | 36 ++++++++--------------- src/entt/entity/handle.hpp | 13 +++------ src/entt/entity/observer.hpp | 7 +++-- src/entt/entity/organizer.hpp | 36 +++++++++++------------ src/entt/entity/registry.hpp | 48 +++++++++++++++---------------- src/entt/entity/runtime_view.hpp | 12 ++++---- src/entt/entity/sparse_set.hpp | 4 +-- src/entt/entity/view.hpp | 11 +++---- src/entt/meta/factory.hpp | 28 ++++++++++-------- src/entt/meta/meta.hpp | 12 ++++++-- src/entt/meta/node.hpp | 6 ++-- src/entt/meta/resolve.hpp | 8 +++--- src/entt/process/process.hpp | 7 ++++- src/entt/signal/delegate.hpp | 9 ++---- src/entt/signal/emitter.hpp | 4 +-- src/entt/signal/sigh.hpp | 8 ++---- 21 files changed, 137 insertions(+), 152 deletions(-) diff --git a/src/entt/core/any.hpp b/src/entt/core/any.hpp index f007f4319..63450e358 100644 --- a/src/entt/core/any.hpp +++ b/src/entt/core/any.hpp @@ -23,8 +23,13 @@ namespace entt { */ template class basic_any { - enum class operation: std::uint8_t { COPY, MOVE, DTOR, COMP, GET, TYPE }; - enum class policy: std::uint8_t { OWNER, REF, CREF }; + enum class operation: std::uint8_t { + COPY, MOVE, DTOR, COMP, GET, TYPE + }; + + enum class policy: std::uint8_t { + OWNER, REF, CREF + }; using storage_type = std::aligned_storage_t; using vtable_type = const void *(const operation, const basic_any &, const void *); diff --git a/src/entt/core/compressed_pair.hpp b/src/entt/core/compressed_pair.hpp index c898df8ac..533ff167c 100644 --- a/src/entt/core/compressed_pair.hpp +++ b/src/entt/core/compressed_pair.hpp @@ -53,9 +53,7 @@ private: template -struct compressed_pair_element>> - : Type -{ +struct compressed_pair_element>>: Type { template>> compressed_pair_element() : Type{} @@ -100,9 +98,8 @@ struct compressed_pair_element -class compressed_pair final: - internal::compressed_pair_element, - internal::compressed_pair_element +class compressed_pair final + : internal::compressed_pair_element, internal::compressed_pair_element { using first_base = internal::compressed_pair_element; using second_base = internal::compressed_pair_element; @@ -245,8 +242,7 @@ public: * @tparam Other Type of value to use to initialize the second element. */ template -compressed_pair(Type &&, Other &&) --> compressed_pair, std::decay_t>; +compressed_pair(Type &&, Other &&) -> compressed_pair, std::decay_t>; /** diff --git a/src/entt/core/hashed_string.hpp b/src/entt/core/hashed_string.hpp index c799d8f6f..f7cb24ebb 100644 --- a/src/entt/core/hashed_string.hpp +++ b/src/entt/core/hashed_string.hpp @@ -203,8 +203,7 @@ private: * @param str Human-readable identifer. */ template -basic_hashed_string(const Char (&str)[N]) --> basic_hashed_string; +basic_hashed_string(const Char (&str)[N]) -> basic_hashed_string; /** diff --git a/src/entt/core/type_traits.hpp b/src/entt/core/type_traits.hpp index 5bb300166..0bf2ca4bf 100644 --- a/src/entt/core/type_traits.hpp +++ b/src/entt/core/type_traits.hpp @@ -20,9 +20,7 @@ namespace entt { template struct choice_t // Unfortunately, doxygen cannot parse such a construct. - /*! @cond TURN_OFF_DOXYGEN */ - : choice_t - /*! @endcond */ + : /*! @cond TURN_OFF_DOXYGEN */ choice_t /*! @endcond */ {}; @@ -595,13 +593,11 @@ template 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()) { +[[nodiscard]] constexpr auto is_equality_comparable(choice_t<1>) -> decltype(std::declval(), std::declval() == std::declval()) { if constexpr(is_iterator_v) { return true; } else if constexpr(std::is_same_v) { @@ -613,8 +609,7 @@ template template -[[nodiscard]] constexpr auto is_equality_comparable(choice_t<2>) --> decltype(std::declval(), std::declval() == std::declval()) { +[[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>); } diff --git a/src/entt/core/utility.hpp b/src/entt/core/utility.hpp index 4e081b742..5a7ec16a9 100644 --- a/src/entt/core/utility.hpp +++ b/src/entt/core/utility.hpp @@ -60,8 +60,7 @@ struct overloaded: Func... { * @tparam Func Types of function objects. */ template -overloaded(Func...) --> overloaded; +overloaded(Func...) -> overloaded; /** diff --git a/src/entt/entity/group.hpp b/src/entt/entity/group.hpp index 39588c087..e61b66919 100644 --- a/src/entt/entity/group.hpp +++ b/src/entt/entity/group.hpp @@ -442,7 +442,7 @@ public: static_assert(std::is_invocable_v, "Invalid comparison function"); handler->sort(std::move(compare), std::move(algo), std::forward(args)...); } else { - auto forward_compare = [this, &compare](const entity_type lhs, const entity_type rhs) { + auto comp = [this, &compare](const entity_type lhs, const entity_type rhs) { if constexpr(sizeof...(Component) == 1) { return compare((std::get *>(pools)->get(lhs), ...), (std::get *>(pools)->get(rhs), ...)); } else { @@ -450,7 +450,7 @@ public: } }; - handler->sort(std::move(forward_compare), std::move(algo), std::forward(args)...); + handler->sort(std::move(comp), std::move(algo), std::forward(args)...); } } } @@ -606,35 +606,23 @@ class basic_group, get_t, exclude_t(pools)->basic_common_type::end() - *length, - std::make_tuple((std::get *>(pools)->end() - *length)...), - std::make_tuple(std::get *>(pools)...) - } : iterator{{}, std::make_tuple(decltype(std::get *>(pools)->end()){}...), std::make_tuple(std::get *>(pools)...)}; + auto it = length ? (std::get<0>(pools)->basic_common_type::end() - *length) : typename basic_common_type::iterator{}; + return iterator{std::move(it), std::make_tuple((std::get *>(pools)->end() - *length)...), std::make_tuple(std::get *>(pools)...)}; } [[nodiscard]] iterator end() const ENTT_NOEXCEPT { - return length ? iterator{ - std::get<0>(pools)->basic_common_type::end(), - std::make_tuple((std::get *>(pools)->end())...), - std::make_tuple(std::get *>(pools)...) - } : iterator{{}, std::make_tuple(decltype(std::get *>(pools)->end()){}...), std::make_tuple(std::get *>(pools)...)}; + auto it = length ? std::get<0>(pools)->basic_common_type::end() : typename basic_common_type::iterator{}; + return iterator{std::move(it), std::make_tuple((std::get *>(pools)->end())...), std::make_tuple(std::get *>(pools)...)}; } [[nodiscard]] reverse_iterator rbegin() const ENTT_NOEXCEPT { - return length ? reverse_iterator{ - std::get<0>(pools)->basic_common_type::rbegin(), - std::make_tuple((std::get *>(pools)->rbegin())...), - std::make_tuple(std::get *>(pools)...) - } : reverse_iterator{{}, std::make_tuple(decltype(std::get *>(pools)->rbegin()){}...), std::make_tuple(std::get *>(pools)...)}; + auto it = length ? std::get<0>(pools)->basic_common_type::rbegin() : typename basic_common_type::reverse_iterator{}; + return reverse_iterator{std::move(it), std::make_tuple((std::get *>(pools)->rbegin())...), std::make_tuple(std::get *>(pools)...)}; } [[nodiscard]] reverse_iterator rend() const ENTT_NOEXCEPT { - return length ? reverse_iterator{ - std::get<0>(pools)->basic_common_type::rbegin() + *length, - std::make_tuple((std::get *>(pools)->rbegin() + *length)...), - std::make_tuple(std::get *>(pools)...) - } : reverse_iterator{{}, std::make_tuple(decltype(std::get *>(pools)->rbegin()){}...), std::make_tuple(std::get *>(pools)...)}; + auto it = length ? (std::get<0>(pools)->basic_common_type::rbegin() + *length) : typename basic_common_type::reverse_iterator{}; + return reverse_iterator{std::move(it), std::make_tuple((std::get *>(pools)->rbegin() + *length)...), std::make_tuple(std::get *>(pools)...)}; } private: @@ -941,7 +929,7 @@ public: static_assert(std::is_invocable_v, "Invalid comparison function"); cpool->sort_n(*length, std::move(compare), std::move(algo), std::forward(args)...); } else { - auto forward_compare = [this, &compare](const entity_type lhs, const entity_type rhs) { + auto comp = [this, &compare](const entity_type lhs, const entity_type rhs) { if constexpr(sizeof...(Component) == 1) { return compare((std::get *>(pools)->get(lhs), ...), (std::get *>(pools)->get(rhs), ...)); } else { @@ -949,7 +937,7 @@ public: } }; - cpool->sort_n(*length, std::move(forward_compare), std::move(algo), std::forward(args)...); + cpool->sort_n(*length, std::move(comp), std::move(algo), std::forward(args)...); } [this](auto *head, auto *... other) { diff --git a/src/entt/entity/handle.hpp b/src/entt/entity/handle.hpp index 19fc94efe..d9a39a3b2 100644 --- a/src/entt/entity/handle.hpp +++ b/src/entt/entity/handle.hpp @@ -56,11 +56,8 @@ struct basic_handle { */ template operator basic_handle() const ENTT_NOEXCEPT { - static_assert( - (std::is_same_v || std::is_same_v, Entity>) - && (sizeof...(Type) == 0 || ((sizeof...(Args) != 0 && sizeof...(Args) <= sizeof...(Type)) && ... && (type_list_contains_v, Args>))), - "Invalid conversion between different handles" - ); + static_assert(std::is_same_v || std::is_same_v, Entity>, "Invalid conversion between different handles"); + static_assert((sizeof...(Type) == 0 || ((sizeof...(Args) != 0 && sizeof...(Args) <= sizeof...(Type)) && ... && (type_list_contains_v, Args>))), "Invalid conversion between different handles"); return reg ? basic_handle{*reg, entt} : basic_handle{}; } @@ -322,8 +319,7 @@ template * @tparam Entity A valid entity type (see entt_traits for more details). */ template -basic_handle(basic_registry &, Entity) --> basic_handle; +basic_handle(basic_registry &, Entity) -> basic_handle; /** @@ -331,8 +327,7 @@ basic_handle(basic_registry &, Entity) * @tparam Entity A valid entity type (see entt_traits for more details). */ template -basic_handle(const basic_registry &, Entity) --> basic_handle; +basic_handle(const basic_registry &, Entity) -> basic_handle; } diff --git a/src/entt/entity/observer.hpp b/src/entt/entity/observer.hpp index 366520349..733ce953e 100644 --- a/src/entt/entity/observer.hpp +++ b/src/entt/entity/observer.hpp @@ -215,14 +215,15 @@ class basic_observer { struct matcher_handler, type_list, type_list, AllOf...>> { template static void maybe_valid_if(basic_observer &obs, basic_registry ®, const Entity entt) { - if([®, entt]() { + auto condition = [®, entt]() { if constexpr(sizeof...(Ignore) == 0) { return reg.template all_of(entt) && !reg.template any_of(entt); } else { return reg.template all_of(entt) && ((std::is_same_v || !reg.template any_of(entt)) && ...) && !reg.template any_of(entt); } - }()) - { + }; + + if(condition()) { if(!obs.storage.contains(entt)) { obs.storage.emplace(entt); } diff --git a/src/entt/entity/organizer.hpp b/src/entt/entity/organizer.hpp index e919bd25e..934ffbf87 100644 --- a/src/entt/entity/organizer.hpp +++ b/src/entt/entity/organizer.hpp @@ -381,9 +381,7 @@ public: std::apply(Candidate, to_args(reg, typename resource_type::args{})); }; - track_dependencies(vertices.size(), requires_registry, typename resource_type::ro{}, typename resource_type::rw{}); - - vertices.push_back({ + vertex_data vdata { resource_type::ro::size, resource_type::rw::size, name, @@ -392,7 +390,10 @@ public: +[](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>() - }); + }; + + track_dependencies(vertices.size(), requires_registry, typename resource_type::ro{}, typename resource_type::rw{}); + vertices.push_back(std::move(vdata)); } /** @@ -414,22 +415,19 @@ public: std::apply(Candidate, std::tuple_cat(std::forward_as_tuple(*curr), to_args(reg, typename resource_type::args{}))); }; - track_dependencies(vertices.size(), requires_registry, typename resource_type::ro{}, typename resource_type::rw{}); - - vertices.push_back({ + vertex_data vdata { resource_type::ro::size, resource_type::rw::size, name, &value_or_instance, 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{})); - }, + +[](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>() - }); + }; + + track_dependencies(vertices.size(), requires_registry, typename resource_type::ro{}, typename resource_type::rw{}); + vertices.push_back(std::move(vdata)); } /** @@ -445,18 +443,18 @@ public: using resource_type = internal::resource, type_list>; track_dependencies(vertices.size(), true, typename resource_type::ro{}, typename resource_type::rw{}); - vertices.push_back({ + vertex_data vdata { resource_type::ro::size, resource_type::rw::size, name, payload, 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); - }, + +[](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{} - }); + }; + + vertices.push_back(std::move(vdata)); } /** diff --git a/src/entt/entity/registry.hpp b/src/entt/entity/registry.hpp index 89f909b83..a5d400698 100644 --- a/src/entt/entity/registry.hpp +++ b/src/entt/entity/registry.hpp @@ -389,7 +389,7 @@ public: return create(); } else { auto *it = &free_list; - for(; entity_traits::to_entity(*it) != req; it = &entities[entity_traits::to_entity(*it)]); + for(; entity_traits::to_entity(*it) != req; it = &entities[entity_traits::to_entity(*it)]) { continue; } *it = entity_traits::combine(curr, entity_traits::to_integral(*it)); return (entities[req] = hint); } @@ -1215,17 +1215,16 @@ public: constexpr auto size = sizeof...(Owned) + sizeof...(Get) + sizeof...(Exclude); handler_type *handler = nullptr; - if(auto it = std::find_if(groups.cbegin(), groups.cend(), [size](const auto &gdata) { + auto it = std::find_if(groups.cbegin(), groups.cend(), [size](const auto &gdata) { return gdata.size == size - && (gdata.owned(type_hash>::value()) && ...) - && (gdata.get(type_hash>::value()) && ...) - && (gdata.exclude(type_hash::value()) && ...); - }); it != groups.cend()) - { - handler = static_cast(it->group.get()); - } + && (gdata.owned(type_hash>::value()) && ...) + && (gdata.get(type_hash>::value()) && ...) + && (gdata.exclude(type_hash::value()) && ...); + }); - if(!handler) { + if(it != groups.cend()) { + handler = static_cast(it->group.get()); + } else { group_data candidate = { size, { new handler_type{}, [](void *instance) { delete static_cast(instance); } }, @@ -1242,11 +1241,13 @@ public: if constexpr(sizeof...(Owned) == 0) { groups.push_back(std::move(candidate)); } else { - ENTT_ASSERT(std::all_of(groups.cbegin(), groups.cend(), [size](const auto &gdata) { + [[maybe_unused]] auto has_conflict = [size](const auto &gdata) { const auto overlapping = (0u + ... + gdata.owned(type_hash>::value())); const auto sz = overlapping + (0u + ... + gdata.get(type_hash>::value())) + (0u + ... + gdata.exclude(type_hash::value())); return !overlapping || ((sz == size) || (sz == gdata.size)); - }), "Conflicting groups"); + }; + + ENTT_ASSERT(std::all_of(groups.cbegin(), groups.cend(), std::move(has_conflict)), "Conflicting groups"); const auto next = std::find_if_not(groups.cbegin(), groups.cend(), [size](const auto &gdata) { return !(0u + ... + gdata.owned(type_hash>::value())) || (size > gdata.size); @@ -1296,13 +1297,14 @@ public: */ template [[nodiscard]] basic_group...>, get_t...>, exclude_t> group_if_exists(get_t, exclude_t = {}) const { - if(auto it = std::find_if(groups.cbegin(), groups.cend(), [](const auto &gdata) { + auto it = std::find_if(groups.cbegin(), groups.cend(), [](const auto &gdata) { return gdata.size == (sizeof...(Owned) + sizeof...(Get) + sizeof...(Exclude)) - && (gdata.owned(type_hash>::value()) && ...) - && (gdata.get(type_hash>::value()) && ...) - && (gdata.exclude(type_hash::value()) && ...); - }); it == groups.cend()) - { + && (gdata.owned(type_hash>::value()) && ...) + && (gdata.get(type_hash>::value()) && ...) + && (gdata.exclude(type_hash::value()) && ...); + }); + + if(it == groups.cend()) { return {}; } else { using handler_type = group_handler, get_t...>, std::remove_const_t...>; @@ -1359,9 +1361,8 @@ public: template [[nodiscard]] bool sortable(const basic_group, get_t, exclude_t> &) ENTT_NOEXCEPT { constexpr auto size = sizeof...(Owned) + sizeof...(Get) + sizeof...(Exclude); - return std::find_if(groups.cbegin(), groups.cend(), [size](const auto &gdata) { - return (0u + ... + gdata.owned(type_hash>::value())) && (size < gdata.size); - }) == groups.cend(); + auto pred = [size](const auto &gdata) { return (0u + ... + gdata.owned(type_hash>::value())) && (size < gdata.size); }; + return std::find_if(groups.cbegin(), groups.cend(), std::move(pred)) == groups.cend(); } /** @@ -1418,9 +1419,8 @@ public: cpool->sort(std::move(compare), std::move(algo), std::forward(args)...); } else { if constexpr(std::is_invocable_vget({})), decltype(cpool->get({}))>) { - cpool->sort([cpool, compare = std::move(compare)](const auto lhs, const auto rhs) { - return compare(std::as_const(cpool->get(lhs)), std::as_const(cpool->get(rhs))); - }, std::move(algo), std::forward(args)...); + auto comp = [cpool, compare = std::move(compare)](const auto lhs, const auto rhs) { return compare(std::as_const(cpool->get(lhs)), std::as_const(cpool->get(rhs))); }; + cpool->sort(std::move(comp), std::move(algo), std::forward(args)...); } else { cpool->sort(std::move(compare), std::move(algo), std::forward(args)...); } diff --git a/src/entt/entity/runtime_view.hpp b/src/entt/entity/runtime_view.hpp index d3c7e9946..886a982b5 100644 --- a/src/entt/entity/runtime_view.hpp +++ b/src/entt/entity/runtime_view.hpp @@ -87,7 +87,7 @@ class basic_runtime_view final { } view_iterator & operator++() { - while(++it != (*pools)[0]->end() && !valid()); + while(++it != (*pools)[0]->end() && !valid()) { continue; } return *this; } @@ -97,7 +97,7 @@ class basic_runtime_view final { } view_iterator & operator--() ENTT_NOEXCEPT { - while(--it != (*pools)[0]->begin() && !valid()); + while(--it != (*pools)[0]->begin() && !valid()) { continue; } return *this; } @@ -156,10 +156,12 @@ public: : pools{std::move(cpools)}, filter{std::move(epools)} { - // brings the best candidate (if any) on front of the vector - std::rotate(pools.begin(), std::min_element(pools.begin(), pools.end(), [](const auto *lhs, const auto *rhs) { + auto candidate = std::min_element(pools.begin(), pools.end(), [](const auto *lhs, const auto *rhs) { return (!lhs && rhs) || (lhs && rhs && lhs->size() < rhs->size()); - }), pools.end()); + }); + + // brings the best candidate (if any) on front of the vector + std::rotate(pools.begin(), candidate, pools.end()); } /** diff --git a/src/entt/entity/sparse_set.hpp b/src/entt/entity/sparse_set.hpp index 9e0c7b8fc..53c6a02da 100644 --- a/src/entt/entity/sparse_set.hpp +++ b/src/entt/entity/sparse_set.hpp @@ -771,7 +771,7 @@ public: /*! @brief Removes all tombstones from the packed array of a sparse set. */ void compact() { size_type next = count; - for(; next && packed[next - 1u] == tombstone; --next); + for(; next && packed[next - 1u] == tombstone; --next) { continue; } for(auto *it = &free_list; *it != null && next; it = std::addressof(packed[entity_traits::to_entity(*it)])) { if(const size_type pos = entity_traits::to_entity(*it); pos < next) { @@ -781,7 +781,7 @@ public: const auto entity = static_cast(pos); sparse_ref(packed[pos]) = entity_traits::combine(entity, entity_traits::to_integral(packed[pos])); *it = entity_traits::combine(static_cast(next), entity_traits::reserved); - for(; next && packed[next - 1u] == tombstone; --next); + for(; next && packed[next - 1u] == tombstone; --next) { continue; } } } diff --git a/src/entt/entity/view.hpp b/src/entt/entity/view.hpp index 47d3bbbad..15e6cc0d6 100644 --- a/src/entt/entity/view.hpp +++ b/src/entt/entity/view.hpp @@ -149,7 +149,7 @@ public: } view_iterator & operator++() ENTT_NOEXCEPT { - while(++it != last && !valid()); + while(++it != last && !valid()) { continue; } return *this; } @@ -159,7 +159,7 @@ public: } view_iterator & operator--() ENTT_NOEXCEPT { - while(--it != first && !valid()); + while(--it != first && !valid()) { continue; } return *this; } @@ -689,9 +689,7 @@ private: * @tparam Component Type of component iterated by the view. */ template -class basic_view, exclude_t<>, - // Yeah, there is a reason why void_t and enable_if_t were combined here. Try removing the first one and let me know. :) - std::void_t>>> +class basic_view, exclude_t<>, std::void_t>>> > { template friend class basic_view; @@ -1001,8 +999,7 @@ private: * @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<>>; } diff --git a/src/entt/meta/factory.hpp b/src/entt/meta/factory.hpp index 7f1d638fe..24b749e3d 100644 --- a/src/entt/meta/factory.hpp +++ b/src/entt/meta/factory.hpp @@ -77,6 +77,7 @@ class meta_factory: public meta_factory { nullptr, property[0u], property[1u] + // tricks clang-format }; property[0u] = std::move(key); @@ -199,6 +200,7 @@ class meta_factory { &meta_arg::size != 1u, type_list_element_t>...>>, [](meta_handle instance, meta_any value) -> bool { return (meta_setter>(*instance.operator->(), value) || ...); }, &meta_getter + // tricks clang-format }; link_data_if_required(id, node); @@ -244,9 +246,8 @@ public: static internal::meta_base_node node{ nullptr, internal::meta_node::resolve(), - [](const void *instance) ENTT_NOEXCEPT -> const void * { - return static_cast(static_cast(instance)); - } + [](const void *instance) ENTT_NOEXCEPT -> const void * { return static_cast(static_cast(instance)); } + // tricks clang-format }; link_base_if_required(node); @@ -272,9 +273,8 @@ public: static internal::meta_conv_node node{ nullptr, internal::meta_node::resolve(), - [](const void *instance) -> meta_any { - return forward_as_meta(static_cast(instance)->*Candidate)(); - } + [](const void *instance) -> meta_any { return forward_as_meta(static_cast(instance)->*Candidate)(); } + // tricks clang-format }; link_conv_if_required(node); @@ -289,9 +289,8 @@ public: static internal::meta_conv_node node{ nullptr, internal::meta_node::resolve(), - [](const void *instance) -> meta_any { - return forward_as_meta(Candidate(*static_cast(instance))); - } + [](const void *instance) -> meta_any { return forward_as_meta(Candidate(*static_cast(instance))); } + // tricks clang-format }; link_conv_if_required(node); @@ -314,9 +313,8 @@ public: static internal::meta_conv_node node{ nullptr, internal::meta_node>>::resolve(), - [](const void *instance) -> meta_any { - return forward_as_meta(static_cast(*static_cast(instance))); - } + [](const void *instance) -> meta_any { return forward_as_meta(static_cast(*static_cast(instance))); } + // tricks clang-format }; link_conv_if_required(node); @@ -346,6 +344,7 @@ public: descriptor::args_type::size, &meta_arg, &meta_construct + // tricks clang-format }; link_ctor_if_required(node); @@ -371,6 +370,7 @@ public: descriptor::args_type::size, &meta_arg, &meta_construct + // tricks clang-format }; link_ctor_if_required(node); @@ -430,6 +430,7 @@ public: &meta_arg>, &meta_setter, &meta_getter + // tricks clang-format }; link_data_if_required(id, node); @@ -473,6 +474,7 @@ public: &meta_arg>, &meta_setter, &meta_getter + // tricks clang-format }; link_data_if_required(id, node); @@ -491,6 +493,7 @@ public: &meta_arg>>, &meta_setter, &meta_getter + // tricks clang-format }; link_data_if_required(id, node); @@ -546,6 +549,7 @@ public: internal::meta_node, void, std::remove_const_t>>>::resolve(), &meta_arg, &meta_invoke + // tricks clang-format }; link_func_if_required(id, node); diff --git a/src/entt/meta/meta.hpp b/src/entt/meta/meta.hpp index 552e6be5b..0e4cdae54 100644 --- a/src/entt/meta/meta.hpp +++ b/src/entt/meta/meta.hpp @@ -153,7 +153,9 @@ private: /*! @brief Opaque wrapper for values of any type. */ class meta_any { - enum class operation { DEREF, SEQ, ASSOC }; + enum class operation: std::uint8_t { + DEREF, SEQ, ASSOC + }; using vtable_type = void(const operation, const any &, void *); @@ -1436,7 +1438,9 @@ bool meta_any::set(const id_type id, Type &&value) { /*! @brief Opaque iterator for sequence containers. */ class meta_sequence_container::meta_iterator { - enum class operation { INCR, DEREF }; + enum class operation: std::uint8_t { + INCR, DEREF + }; using vtable_type = void(const operation, const any &, void *); @@ -1637,7 +1641,9 @@ inline meta_sequence_container::iterator meta_sequence_container::erase(iterator /*! @brief Opaque iterator for associative containers. */ class meta_associative_container::meta_iterator { - enum class operation { INCR, DEREF }; + enum class operation: std::uint8_t { + INCR, DEREF + }; using vtable_type = void(const operation, const any &, void *); diff --git a/src/entt/meta/node.hpp b/src/entt/meta/node.hpp index fd6889901..9d5635f6e 100644 --- a/src/entt/meta/node.hpp +++ b/src/entt/meta/node.hpp @@ -170,9 +170,8 @@ class ENTT_API meta_node { static meta_template_node node{ meta_template_traits::args_type::size, meta_node::class_type>::resolve(), - [](const std::size_t index) ENTT_NOEXCEPT { - return meta_arg_node(typename meta_template_traits::args_type{}, index); - } + [](const std::size_t index) ENTT_NOEXCEPT { return meta_arg_node(typename meta_template_traits::args_type{}, index); } + // tricks clang-format }; return &node; @@ -201,6 +200,7 @@ public: meta_default_constructor(), meta_conversion_helper(), meta_template_info() + // tricks clang-format }; return &node; diff --git a/src/entt/meta/resolve.hpp b/src/entt/meta/resolve.hpp index 0883c9aae..2cb4a47c4 100644 --- a/src/entt/meta/resolve.hpp +++ b/src/entt/meta/resolve.hpp @@ -39,8 +39,8 @@ template * @return The meta type associated with the given identifier, if any. */ [[nodiscard]] inline meta_type resolve(const id_type id) ENTT_NOEXCEPT { - for(auto *curr = *internal::meta_context::global(); curr; curr = curr->next) { - if(curr->id == id) { + for(auto &&curr: resolve()) { + if(curr.id() == id) { return curr; } } @@ -56,8 +56,8 @@ template * @return The meta type associated with the given type info object, if any. */ [[nodiscard]] inline meta_type resolve(const type_info info) ENTT_NOEXCEPT { - for(auto *curr = *internal::meta_context::global(); curr; curr = curr->next) { - if(curr->info == info) { + for(auto &&curr: resolve()) { + if(curr.info() == info) { return curr; } } diff --git a/src/entt/process/process.hpp b/src/entt/process/process.hpp index 93a0c4b80..da69bcfbb 100644 --- a/src/entt/process/process.hpp +++ b/src/entt/process/process.hpp @@ -323,7 +323,12 @@ struct process_adaptor: process, Delta>, private Fu * @param data Optional data. */ void update(const Delta delta, void *data) { - Func::operator()(delta, data, [this]() { this->succeed(); }, [this]() { this->fail(); }); + Func::operator()( + delta, + data, + [this]() { this->succeed(); }, + [this]() { this->fail(); } + ); } }; diff --git a/src/entt/signal/delegate.hpp b/src/entt/signal/delegate.hpp index e8be93f08..e23fd2b4e 100644 --- a/src/entt/signal/delegate.hpp +++ b/src/entt/signal/delegate.hpp @@ -335,8 +335,7 @@ template * @tparam Candidate Function or member to connect to the delegate. */ template -delegate(connect_arg_t) --> delegate>>; +delegate(connect_arg_t) -> delegate>>; /** @@ -345,8 +344,7 @@ delegate(connect_arg_t) * @tparam Type Type of class or type of payload. */ template -delegate(connect_arg_t, Type &&) --> delegate>>; +delegate(connect_arg_t, Type &&) -> delegate>>; /** @@ -355,8 +353,7 @@ delegate(connect_arg_t, 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; } diff --git a/src/entt/signal/emitter.hpp b/src/entt/signal/emitter.hpp index 45df1b1cc..99469f6f9 100644 --- a/src/entt/signal/emitter.hpp +++ b/src/entt/signal/emitter.hpp @@ -59,8 +59,8 @@ class emitter { [[nodiscard]] bool empty() const ENTT_NOEXCEPT override { 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); + return std::all_of(once_list.cbegin(), once_list.cend(), pred) + && std::all_of(on_list.cbegin(), on_list.cend(), pred); } void clear() ENTT_NOEXCEPT override { diff --git a/src/entt/signal/sigh.hpp b/src/entt/signal/sigh.hpp index 95edb71fd..c39d6c9de 100644 --- a/src/entt/signal/sigh.hpp +++ b/src/entt/signal/sigh.hpp @@ -501,9 +501,8 @@ public: void disconnect(Type *value_or_instance) { if(value_or_instance) { auto &calls = signal->calls; - calls.erase(std::remove_if(calls.begin(), calls.end(), [value_or_instance](const auto &delegate) { - return delegate.instance() == value_or_instance; - }), calls.end()); + auto predicate = [value_or_instance](const auto &delegate) { return delegate.instance() == value_or_instance; }; + calls.erase(std::remove_if(calls.begin(), calls.end(), std::move(predicate)), calls.end()); } } @@ -528,8 +527,7 @@ private: * @tparam Args Types of arguments of a function type. */ template -sink(sigh &) --> sink; +sink(sigh &) -> sink; }