From 1bb4bcecdc9d8f2059770217cc32d29726dd0ea4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 18 Nov 2022 12:28:42 +0100 Subject: entity: reformat only --- entity/entity.hpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'entity') diff --git a/entity/entity.hpp b/entity/entity.hpp index 30c75c15..9b64da56 100644 --- a/entity/entity.hpp +++ b/entity/entity.hpp @@ -77,8 +77,9 @@ struct read_field { static constexpr Type read(const Obj& x, Type Obj::*r) { return x.*r; } }; -template -struct read_field) const>> { +template +struct read_field) const>> +{ template static constexpr Type read(const Obj& x, F&& fun) { return fun(x); } }; @@ -96,8 +97,8 @@ struct write_field { static constexpr void write(Obj& x, FieldType Obj::* w, move_qualified value) { x.*w = value; } }; -template -struct write_field) const>> { +template +struct write_field) const>> { template static constexpr void write(Obj& x, F&& fun, move_qualified value) { fun(x, value); } }; @@ -132,7 +133,8 @@ constexpr CORRADE_ALWAYS_INLINE bool find_in_tuple(F&& fun, Tuple&& tuple) return false; } -template struct decay_tuple_; template struct decay_tuple_> { using type = std::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 using accessors_for = typename accessors_for_::type; @@ -155,7 +157,7 @@ struct entity_field : entity_field_base { constexpr entity_field(const entity_field&) = default; constexpr entity_field& operator=(const entity_field&) = default; static constexpr decltype(auto) read(const R& reader, const Obj& x) { return detail::read_field::read(x, reader); } - static constexpr void write(const W& writer, Obj& x, move_qualified v) { detail::write_field::write(x, writer, v); } + static constexpr void write(const W& writer, Obj& x, move_qualified v); constexpr decltype(auto) read(const Obj& x) const { return read(reader, x); } constexpr void write(Obj& x, move_qualified value) const { write(writer, x, value); } static constexpr bool can_write = !std::is_same_v::writer)>; @@ -163,6 +165,12 @@ struct entity_field : entity_field_base { constexpr erased_accessor erased() const; }; +template R, FieldWriter W> +constexpr void entity_field::write(const W& writer, Obj& x, move_qualified v) +{ + static_assert(can_write); detail::write_field::write(x, writer, v); +} + template R, FieldWriter W> constexpr erased_accessor entity_field::erased() const { -- cgit v1.2.3