|
|
@@ -82,13 +82,21 @@ public:
|
|
|
return *this;
|
|
|
}
|
|
|
|
|
|
- template <typename F> Reflection & bind(std::string_view id, F func) {
|
|
|
- if constexpr (!std::is_const_v<decltype(func(std::declval<Obj &>()))>) {
|
|
|
- members_.emplace(id, REFLECTION_F(func(obj)));
|
|
|
+ template <typename Get, typename Set>
|
|
|
+ Reflection & bind(std::string_view id, Get get, Set set) {
|
|
|
+ using V = std::decay_t<std::invoke_result_t<Get, Obj &>>;
|
|
|
+ members_.emplace(id, REFLECTION_F(Proxy<V>(obj, get, set)));
|
|
|
+ const_members_.emplace(id, CONST_REFLECTION_F(get(obj)));
|
|
|
+ return *this;
|
|
|
+ }
|
|
|
+
|
|
|
+ template <typename Get> Reflection & bind(std::string_view id, Get get) {
|
|
|
+ if constexpr (!std::is_const_v<std::invoke_result_t<Get, Obj &>>) {
|
|
|
+ members_.emplace(id, REFLECTION_F(get(obj)));
|
|
|
} else {
|
|
|
- members_.emplace(id, CONST_REFLECTION_F(func(obj)));
|
|
|
+ members_.emplace(id, CONST_REFLECTION_F(get(obj)));
|
|
|
}
|
|
|
- const_members_.emplace(id, CONST_REFLECTION_F(func(obj)));
|
|
|
+ const_members_.emplace(id, CONST_REFLECTION_F(get(obj)));
|
|
|
return *this;
|
|
|
}
|
|
|
|