From cb665e2f6a829285f37abc72d03e434707f5af0d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 19 Nov 2022 18:31:08 +0100 Subject: entity: get field data indirectly via a specialization so now classes will be able to #ifdef including `entity/metadata.hpp` and specifying the fields without incurring an ODR violation. --- entity/metadata.hpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'entity') diff --git a/entity/metadata.hpp b/entity/metadata.hpp index 935f1792..0014f63c 100644 --- a/entity/metadata.hpp +++ b/entity/metadata.hpp @@ -15,6 +15,12 @@ #include #include +namespace floormat::entities { + +template struct entity_accessors; + +} // namespace floormat::entities + namespace floormat::entities::detail { template @@ -46,7 +52,7 @@ constexpr CORRADE_ALWAYS_INLINE bool find_in_tuple(F&& fun, Tuple&& tuple) template struct decay_tuple_; template struct decay_tuple_> { using type = std::tuple...>; }; template using decay_tuple = typename decay_tuple_::type; -template struct accessors_for_ { using type = decay_tuple>; }; +template struct accessors_for_ { using type = decay_tuple::accessors())>>; }; template using accessors_for = typename accessors_for_::type; template struct find_reader; @@ -269,7 +275,7 @@ class entity_metadata final { public: static constexpr StringView class_name = name_of; static constexpr std::size_t size = std::tuple_size_v>; - static constexpr entities::detail::accessors_for accessors = T::accessors(); + static constexpr entities::detail::accessors_for accessors = entities::entity_accessors::accessors(); static constexpr auto erased_accessors = erased_helper(accessors); }; -- cgit v1.2.3