From c82c854297d216bbc1901ffa9dd18f87a1d514e4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 16 Nov 2022 15:25:48 +0100 Subject: entity: add function2 specializations --- src/entity.hpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') diff --git a/src/entity.hpp b/src/entity.hpp index 50b8a4d0..10df2366 100644 --- a/src/entity.hpp +++ b/src/entity.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include namespace floormat {} @@ -80,6 +81,13 @@ struct read_field { static constexpr Type read(const Obj& x, Type Obj::*r) { return x.*r; } }; +template +struct read_field) const>> { + template static constexpr Type read(const Obj& x, F&& fun) { + return fun(x); + } +}; + template W> struct write_field { static constexpr void write(Obj& x, W w, move_qualified value) { w(x, value); } }; @@ -94,6 +102,13 @@ struct write_field { static constexpr void write(Obj& x, FieldType Obj::* w, move_qualified value) { x.*w = value; } }; +template +struct write_field) const>> { + template static constexpr void write(Obj& x, F&& fun, move_qualified value) { + fun(x, value); + } +}; + constexpr inline int memcmp_(const char* s1, const char* s2, std::size_t n) { #ifdef __GNUC__ -- cgit v1.2.3