stl: std::invoke
This commit is contained in:
@@ -238,7 +238,7 @@ public:
|
||||
template<auto Candidate>
|
||||
auto conv() noexcept {
|
||||
using conv_type = stl::remove_cvref_t<stl::invoke_result_t<decltype(Candidate), Type &>>;
|
||||
auto *const op = +[](const meta_ctx &area, const void *instance) { return forward_as_meta(area, std::invoke(Candidate, *static_cast<const Type *>(instance))); };
|
||||
auto *const op = +[](const meta_ctx &area, const void *instance) { return forward_as_meta(area, stl::invoke(Candidate, *static_cast<const Type *>(instance))); };
|
||||
|
||||
base_type::insert_or_assign(
|
||||
internal::meta_conv_node{
|
||||
|
||||
@@ -196,11 +196,11 @@ namespace internal {
|
||||
|
||||
template<typename Policy, typename Candidate, typename... Args>
|
||||
[[nodiscard]] meta_any meta_invoke_with_args(const meta_ctx &ctx, Candidate &&candidate, Args &&...args) {
|
||||
if constexpr(stl::is_void_v<decltype(std::invoke(stl::forward<Candidate>(candidate), args...))>) {
|
||||
std::invoke(stl::forward<Candidate>(candidate), args...);
|
||||
if constexpr(stl::is_void_v<decltype(stl::invoke(stl::forward<Candidate>(candidate), args...))>) {
|
||||
stl::invoke(stl::forward<Candidate>(candidate), args...);
|
||||
return meta_any{ctx, stl::in_place_type<void>};
|
||||
} else {
|
||||
return meta_dispatch<Policy>(ctx, std::invoke(stl::forward<Candidate>(candidate), args...));
|
||||
return meta_dispatch<Policy>(ctx, stl::invoke(stl::forward<Candidate>(candidate), args...));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ template<typename Type, auto Data>
|
||||
using data_type = type_list_element_t<descriptor::is_static, typename descriptor::args_type>;
|
||||
|
||||
if(auto *const clazz = instance->try_cast<Type>(); clazz && value.allow_cast<data_type>()) {
|
||||
std::invoke(Data, *clazz, value.cast<data_type>());
|
||||
stl::invoke(Data, *clazz, value.cast<data_type>());
|
||||
return true;
|
||||
}
|
||||
} else if constexpr(stl::is_member_object_pointer_v<decltype(Data)>) {
|
||||
@@ -288,7 +288,7 @@ template<typename Type, auto Data>
|
||||
|
||||
if constexpr(!stl::is_array_v<data_type> && !stl::is_const_v<data_type>) {
|
||||
if(auto *const clazz = instance->try_cast<Type>(); clazz && value.allow_cast<data_type>()) {
|
||||
std::invoke(Data, *clazz) = value.cast<data_type>();
|
||||
stl::invoke(Data, *clazz) = value.cast<data_type>();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -320,13 +320,13 @@ template<typename Type, auto Data, meta_policy Policy = as_value_t>
|
||||
if constexpr(!stl::is_array_v<stl::remove_cvref_t<stl::invoke_result_t<decltype(Data), Type &>>>) {
|
||||
if constexpr(stl::is_invocable_v<decltype(Data), Type &>) {
|
||||
if(auto *clazz = instance->try_cast<Type>(); clazz) {
|
||||
return meta_dispatch<Policy>(instance->context(), std::invoke(Data, *clazz));
|
||||
return meta_dispatch<Policy>(instance->context(), stl::invoke(Data, *clazz));
|
||||
}
|
||||
}
|
||||
|
||||
if constexpr(stl::is_invocable_v<decltype(Data), const Type &>) {
|
||||
if(auto *fallback = instance->try_cast<const Type>(); fallback) {
|
||||
return meta_dispatch<Policy>(instance->context(), std::invoke(Data, *fallback));
|
||||
return meta_dispatch<Policy>(instance->context(), stl::invoke(Data, *fallback));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,11 +85,11 @@ class poly_vtable {
|
||||
static void fill_vtable_entry(Ret (*&entry)(Any &, Args...)) noexcept {
|
||||
if constexpr(stl::is_invocable_r_v<Ret, decltype(Candidate), Args...>) {
|
||||
entry = +[](Any &, Args... args) -> Ret {
|
||||
return std::invoke(Candidate, stl::forward<Args>(args)...);
|
||||
return stl::invoke(Candidate, stl::forward<Args>(args)...);
|
||||
};
|
||||
} else {
|
||||
entry = +[](Any &instance, Args... args) -> Ret {
|
||||
return static_cast<Ret>(std::invoke(Candidate, any_cast<constness_as_t<Type, Any> &>(instance), stl::forward<Args>(args)...));
|
||||
return static_cast<Ret>(stl::invoke(Candidate, any_cast<constness_as_t<Type, Any> &>(instance), stl::forward<Args>(args)...));
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ class delegate<Ret(Args...)> {
|
||||
return [](const void *, Args... args) -> return_type {
|
||||
[[maybe_unused]] const auto arguments = stl::forward_as_tuple(stl::forward<Args>(args)...);
|
||||
[[maybe_unused]] constexpr auto offset = !stl::is_invocable_r_v<Ret, decltype(Candidate), type_list_element_t<Index, type_list<Args...>>...> * (sizeof...(Args) - sizeof...(Index));
|
||||
return static_cast<Ret>(std::invoke(Candidate, stl::forward<type_list_element_t<Index + offset, type_list<Args...>>>(stl::get<Index + offset>(arguments))...));
|
||||
return static_cast<Ret>(stl::invoke(Candidate, stl::forward<type_list_element_t<Index + offset, type_list<Args...>>>(stl::get<Index + offset>(arguments))...));
|
||||
};
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ class delegate<Ret(Args...)> {
|
||||
Type *curr = static_cast<Type *>(const_cast<constness_as_t<void, Type> *>(payload));
|
||||
[[maybe_unused]] const auto arguments = stl::forward_as_tuple(stl::forward<Args>(args)...);
|
||||
[[maybe_unused]] constexpr auto offset = !stl::is_invocable_r_v<Ret, decltype(Candidate), Type &, type_list_element_t<Index, type_list<Args...>>...> * (sizeof...(Args) - sizeof...(Index));
|
||||
return static_cast<Ret>(std::invoke(Candidate, *curr, stl::forward<type_list_element_t<Index + offset, type_list<Args...>>>(stl::get<Index + offset>(arguments))...));
|
||||
return static_cast<Ret>(stl::invoke(Candidate, *curr, stl::forward<type_list_element_t<Index + offset, type_list<Args...>>>(stl::get<Index + offset>(arguments))...));
|
||||
};
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ class delegate<Ret(Args...)> {
|
||||
Type *curr = static_cast<Type *>(const_cast<constness_as_t<void, Type> *>(payload));
|
||||
[[maybe_unused]] const auto arguments = stl::forward_as_tuple(stl::forward<Args>(args)...);
|
||||
[[maybe_unused]] constexpr auto offset = !stl::is_invocable_r_v<Ret, decltype(Candidate), Type *, type_list_element_t<Index, type_list<Args...>>...> * (sizeof...(Args) - sizeof...(Index));
|
||||
return static_cast<Ret>(std::invoke(Candidate, curr, stl::forward<type_list_element_t<Index + offset, type_list<Args...>>>(stl::get<Index + offset>(arguments))...));
|
||||
return static_cast<Ret>(stl::invoke(Candidate, curr, stl::forward<type_list_element_t<Index + offset, type_list<Args...>>>(stl::get<Index + offset>(arguments))...));
|
||||
};
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ public:
|
||||
|
||||
if constexpr(stl::is_invocable_r_v<Ret, decltype(Candidate), Args...>) {
|
||||
fn = [](const void *, Args... args) -> return_type {
|
||||
return Ret(std::invoke(Candidate, stl::forward<Args>(args)...));
|
||||
return Ret(stl::invoke(Candidate, stl::forward<Args>(args)...));
|
||||
};
|
||||
} else if constexpr(stl::is_member_pointer_v<decltype(Candidate)>) {
|
||||
fn = wrap<Candidate>(internal::index_sequence_for<type_list_element_t<0, type_list<Args...>>>(internal::function_pointer_t<decltype(Candidate)>{}));
|
||||
@@ -170,7 +170,7 @@ public:
|
||||
if constexpr(stl::is_invocable_r_v<Ret, decltype(Candidate), Type &, Args...>) {
|
||||
fn = [](const void *payload, Args... args) -> return_type {
|
||||
Type *curr = static_cast<Type *>(const_cast<constness_as_t<void, Type> *>(payload));
|
||||
return Ret(std::invoke(Candidate, *curr, stl::forward<Args>(args)...));
|
||||
return Ret(stl::invoke(Candidate, *curr, stl::forward<Args>(args)...));
|
||||
};
|
||||
} else {
|
||||
fn = wrap<Candidate>(value_or_instance, internal::index_sequence_for(internal::function_pointer_t<decltype(Candidate), Type>{}));
|
||||
@@ -194,7 +194,7 @@ public:
|
||||
if constexpr(stl::is_invocable_r_v<Ret, decltype(Candidate), Type *, Args...>) {
|
||||
fn = [](const void *payload, Args... args) -> return_type {
|
||||
Type *curr = static_cast<Type *>(const_cast<constness_as_t<void, Type> *>(payload));
|
||||
return Ret(std::invoke(Candidate, curr, stl::forward<Args>(args)...));
|
||||
return Ret(stl::invoke(Candidate, curr, stl::forward<Args>(args)...));
|
||||
};
|
||||
} else {
|
||||
fn = wrap<Candidate>(value_or_instance, internal::index_sequence_for(internal::function_pointer_t<decltype(Candidate), Type>{}));
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
/*! @cond ENTT_INTERNAL */
|
||||
namespace entt::stl {
|
||||
|
||||
using std::function;
|
||||
using std::equal_to;
|
||||
using std::function;
|
||||
using std::invoke;
|
||||
|
||||
} // namespace entt::stl
|
||||
|
||||
|
||||
Reference in New Issue
Block a user