|
|
@@ -2034,49 +2034,43 @@ inline meta_any construct(meta_any * const args, std::index_sequence<Indexes...>
|
|
|
|
|
|
template<bool Const, typename Type, auto Data>
|
|
|
bool setter([[maybe_unused]] meta_handle handle, [[maybe_unused]] meta_any &any) {
|
|
|
+ bool accepted = false;
|
|
|
+
|
|
|
if constexpr(Const) {
|
|
|
return false;
|
|
|
- } else if constexpr(std::is_function_v<std::remove_pointer_t<decltype(Data)>> || std::is_member_pointer_v<decltype(Data)>) {
|
|
|
- auto execute = [&handle, &any](auto *tag) {
|
|
|
- using data_type = std::remove_pointer_t<decltype(tag)>;
|
|
|
- const bool accepted = any.can_cast<data_type>() || any.convert<data_type>();
|
|
|
- auto *clazz = handle.try_cast<Type>();
|
|
|
-
|
|
|
- if(accepted && clazz) {
|
|
|
- if constexpr(std::is_function_v<std::remove_pointer_t<decltype(Data)>>) {
|
|
|
- Data(*clazz, any.cast<data_type>());
|
|
|
- } else if constexpr(std::is_member_function_pointer_v<decltype(Data)>) {
|
|
|
- (clazz->*Data)(any.cast<data_type>());
|
|
|
- } else /* if constexpr(std::is_member_object_pointer_v<decltype(Data)>) */ {
|
|
|
- clazz->*Data = any.cast<data_type>();
|
|
|
- }
|
|
|
- }
|
|
|
+ } else if constexpr(std::is_function_v<std::remove_pointer_t<decltype(Data)>> || std::is_member_function_pointer_v<decltype(Data)>) {
|
|
|
+ using helper_type = meta_function_helper<std::integral_constant<decltype(Data), Data>>;
|
|
|
+ using data_type = std::decay_t<std::tuple_element_t<!std::is_member_function_pointer_v<decltype(Data)>, typename helper_type::args_type>>;
|
|
|
+ accepted = any.can_cast<data_type>() || any.convert<data_type>();
|
|
|
+ auto *clazz = handle.try_cast<Type>();
|
|
|
|
|
|
- return accepted;
|
|
|
- };
|
|
|
+ if(accepted && clazz) {
|
|
|
+ if constexpr(std::is_function_v<std::remove_pointer_t<decltype(Data)>>) {
|
|
|
+ Data(*clazz, any.cast<data_type>());
|
|
|
+ } else if constexpr(std::is_member_function_pointer_v<decltype(Data)>) {
|
|
|
+ (clazz->*Data)(any.cast<data_type>());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if constexpr(std::is_member_object_pointer_v<decltype(Data)>) {
|
|
|
+ using data_type = std::decay_t<decltype(std::declval<Type>().*Data)>;
|
|
|
+ static_assert(std::is_invocable_v<decltype(Data), Type>);
|
|
|
+ accepted = any.can_cast<data_type>() || any.convert<data_type>();
|
|
|
+ auto *clazz = handle.try_cast<Type>();
|
|
|
|
|
|
- if constexpr(std::is_function_v<std::remove_pointer_t<decltype(Data)>> || std::is_member_function_pointer_v<decltype(Data)>) {
|
|
|
- using helper_type = meta_function_helper<std::integral_constant<decltype(Data), Data>>;
|
|
|
- using data_type = std::tuple_element_t<!std::is_member_function_pointer_v<decltype(Data)>, typename helper_type::args_type>;
|
|
|
- data_type *tag = nullptr;
|
|
|
- return execute(tag);
|
|
|
- } else /* if constexpr(std::is_member_object_pointer_v<decltype(Data)>) */ {
|
|
|
- using data_type = std::decay_t<decltype(std::declval<Type>().*Data)>;
|
|
|
- static_assert(std::is_invocable_v<decltype(Data), Type>);
|
|
|
- data_type *tag = nullptr;
|
|
|
- return execute(tag);
|
|
|
+ if(accepted && clazz) {
|
|
|
+ clazz->*Data = any.cast<data_type>();
|
|
|
}
|
|
|
} else {
|
|
|
static_assert(std::is_pointer_v<decltype(Data)>);
|
|
|
using data_type = std::decay_t<decltype(*Data)>;
|
|
|
- const bool accepted = any.can_cast<data_type>() || any.convert<data_type>();
|
|
|
+ accepted = any.can_cast<data_type>() || any.convert<data_type>();
|
|
|
|
|
|
if(accepted) {
|
|
|
*Data = any.cast<data_type>();
|
|
|
}
|
|
|
-
|
|
|
- return accepted;
|
|
|
}
|
|
|
+
|
|
|
+ return accepted;
|
|
|
}
|
|
|
|
|
|
|