Procházet zdrojové kódy

stl: std::is_invocable*

skypjack před 5 dny
rodič
revize
9bd285bfa8

+ 3 - 3
src/entt/core/type_traits.hpp

@@ -588,7 +588,7 @@ struct is_applicable: stl::false_type {};
  * @tparam Args The list of arguments to use to probe the function type.
  * @tparam Args The list of arguments to use to probe the function type.
  */
  */
 template<typename Func, template<typename...> class Tuple, typename... Args>
 template<typename Func, template<typename...> class Tuple, typename... Args>
-struct is_applicable<Func, Tuple<Args...>>: std::is_invocable<Func, Args...> {};
+struct is_applicable<Func, Tuple<Args...>>: stl::is_invocable<Func, Args...> {};
 
 
 /**
 /**
  * @copybrief is_applicable
  * @copybrief is_applicable
@@ -597,7 +597,7 @@ struct is_applicable<Func, Tuple<Args...>>: std::is_invocable<Func, Args...> {};
  * @tparam Args The list of arguments to use to probe the function type.
  * @tparam Args The list of arguments to use to probe the function type.
  */
  */
 template<typename Func, template<typename...> class Tuple, typename... Args>
 template<typename Func, template<typename...> class Tuple, typename... Args>
-struct is_applicable<Func, const Tuple<Args...>>: std::is_invocable<Func, Args...> {};
+struct is_applicable<Func, const Tuple<Args...>>: stl::is_invocable<Func, Args...> {};
 
 
 /**
 /**
  * @brief Helper variable template.
  * @brief Helper variable template.
@@ -619,7 +619,7 @@ struct is_applicable_r: stl::false_type {};
  * @tparam Args The list of arguments to use to probe the function type.
  * @tparam Args The list of arguments to use to probe the function type.
  */
  */
 template<typename Ret, typename Func, typename... Args>
 template<typename Ret, typename Func, typename... Args>
-struct is_applicable_r<Ret, Func, stl::tuple<Args...>>: std::is_invocable_r<Ret, Func, Args...> {};
+struct is_applicable_r<Ret, Func, stl::tuple<Args...>>: stl::is_invocable_r<Ret, Func, Args...> {};
 
 
 /**
 /**
  * @brief Helper variable template.
  * @brief Helper variable template.

+ 2 - 2
src/entt/entity/group.hpp

@@ -617,7 +617,7 @@ public:
     void sort(Compare compare, Sort algo = Sort{}, Args &&...args) {
     void sort(Compare compare, Sort algo = Sort{}, Args &&...args) {
         if(*this) {
         if(*this) {
             if constexpr(sizeof...(Index) == 0) {
             if constexpr(sizeof...(Index) == 0) {
-                static_assert(std::is_invocable_v<Compare, const entity_type, const entity_type>, "Invalid comparison function");
+                static_assert(stl::is_invocable_v<Compare, const entity_type, const entity_type>, "Invalid comparison function");
                 descriptor->handle().sort(stl::move(compare), stl::move(algo), stl::forward<Args>(args)...);
                 descriptor->handle().sort(stl::move(compare), stl::move(algo), stl::forward<Args>(args)...);
             } else {
             } else {
                 auto comp = [&compare, cpools = pools_for(std::index_sequence_for<Get...>{})](const entity_type lhs, const entity_type rhs) {
                 auto comp = [&compare, cpools = pools_for(std::index_sequence_for<Get...>{})](const entity_type lhs, const entity_type rhs) {
@@ -1018,7 +1018,7 @@ public:
         const auto cpools = pools_for(std::index_sequence_for<Owned...>{}, std::index_sequence_for<Get...>{});
         const auto cpools = pools_for(std::index_sequence_for<Owned...>{}, std::index_sequence_for<Get...>{});
 
 
         if constexpr(sizeof...(Index) == 0) {
         if constexpr(sizeof...(Index) == 0) {
-            static_assert(std::is_invocable_v<Compare, const entity_type, const entity_type>, "Invalid comparison function");
+            static_assert(stl::is_invocable_v<Compare, const entity_type, const entity_type>, "Invalid comparison function");
             storage<0>()->sort_n(descriptor->length(), stl::move(compare), stl::move(algo), stl::forward<Args>(args)...);
             storage<0>()->sort_n(descriptor->length(), stl::move(compare), stl::move(algo), stl::forward<Args>(args)...);
         } else {
         } else {
             auto comp = [&compare, &cpools](const entity_type lhs, const entity_type rhs) {
             auto comp = [&compare, &cpools](const entity_type lhs, const entity_type rhs) {

+ 1 - 1
src/entt/entity/registry.hpp

@@ -1129,7 +1129,7 @@ public:
         ENTT_ASSERT(!owned<Type>(), "Cannot sort owned storage");
         ENTT_ASSERT(!owned<Type>(), "Cannot sort owned storage");
         auto &cpool = assure<Type>();
         auto &cpool = assure<Type>();
 
 
-        if constexpr(std::is_invocable_v<Compare, decltype(cpool.get({})), decltype(cpool.get({}))>) {
+        if constexpr(stl::is_invocable_v<Compare, decltype(cpool.get({})), decltype(cpool.get({}))>) {
             auto comp = [&cpool, compare = stl::move(compare)](const auto lhs, const auto rhs) { return compare(stl::as_const(cpool.get(lhs)), stl::as_const(cpool.get(rhs))); };
             auto comp = [&cpool, compare = stl::move(compare)](const auto lhs, const auto rhs) { return compare(stl::as_const(cpool.get(lhs)), stl::as_const(cpool.get(rhs))); };
             cpool.sort(stl::move(comp), stl::move(algo), stl::forward<Args>(args)...);
             cpool.sort(stl::move(comp), stl::move(algo), stl::forward<Args>(args)...);
         } else {
         } else {

+ 4 - 4
src/entt/meta/utility.hpp

@@ -209,11 +209,11 @@ template<typename Type, typename Policy, typename Candidate, std::size_t... Inde
     using descriptor = meta_function_helper_t<Type, stl::remove_reference_t<Candidate>>;
     using descriptor = meta_function_helper_t<Type, stl::remove_reference_t<Candidate>>;
 
 
     // NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic) - waiting for C++20 (and std::span)
     // NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic) - waiting for C++20 (and std::span)
-    if constexpr(std::is_invocable_v<stl::remove_reference_t<Candidate>, const Type &, type_list_element_t<Index, typename descriptor::args_type>...>) {
+    if constexpr(stl::is_invocable_v<stl::remove_reference_t<Candidate>, const Type &, type_list_element_t<Index, typename descriptor::args_type>...>) {
         if(const auto *const clazz = instance.try_cast<const Type>(); clazz && ((args + Index)->allow_cast<type_list_element_t<Index, typename descriptor::args_type>>() && ...)) {
         if(const auto *const clazz = instance.try_cast<const Type>(); clazz && ((args + Index)->allow_cast<type_list_element_t<Index, typename descriptor::args_type>>() && ...)) {
             return meta_invoke_with_args<Policy>(instance.context(), stl::forward<Candidate>(candidate), *clazz, (args + Index)->cast<type_list_element_t<Index, typename descriptor::args_type>>()...);
             return meta_invoke_with_args<Policy>(instance.context(), stl::forward<Candidate>(candidate), *clazz, (args + Index)->cast<type_list_element_t<Index, typename descriptor::args_type>>()...);
         }
         }
-    } else if constexpr(std::is_invocable_v<stl::remove_reference_t<Candidate>, Type &, type_list_element_t<Index, typename descriptor::args_type>...>) {
+    } else if constexpr(stl::is_invocable_v<stl::remove_reference_t<Candidate>, Type &, type_list_element_t<Index, typename descriptor::args_type>...>) {
         if(auto *const clazz = instance.try_cast<Type>(); clazz && ((args + Index)->allow_cast<type_list_element_t<Index, typename descriptor::args_type>>() && ...)) {
         if(auto *const clazz = instance.try_cast<Type>(); clazz && ((args + Index)->allow_cast<type_list_element_t<Index, typename descriptor::args_type>>() && ...)) {
             return meta_invoke_with_args<Policy>(instance.context(), stl::forward<Candidate>(candidate), *clazz, (args + Index)->cast<type_list_element_t<Index, typename descriptor::args_type>>()...);
             return meta_invoke_with_args<Policy>(instance.context(), stl::forward<Candidate>(candidate), *clazz, (args + Index)->cast<type_list_element_t<Index, typename descriptor::args_type>>()...);
         }
         }
@@ -318,13 +318,13 @@ template<typename Type, auto Data, meta_policy Policy = as_value_t>
 [[nodiscard]] meta_any meta_getter(meta_handle instance) {
 [[nodiscard]] meta_any meta_getter(meta_handle instance) {
     if constexpr(std::is_member_pointer_v<decltype(Data)> || stl::is_function_v<stl::remove_reference_t<stl::remove_pointer_t<decltype(Data)>>>) {
     if constexpr(std::is_member_pointer_v<decltype(Data)> || stl::is_function_v<stl::remove_reference_t<stl::remove_pointer_t<decltype(Data)>>>) {
         if constexpr(!stl::is_array_v<stl::remove_cvref_t<stl::invoke_result_t<decltype(Data), Type &>>>) {
         if constexpr(!stl::is_array_v<stl::remove_cvref_t<stl::invoke_result_t<decltype(Data), Type &>>>) {
-            if constexpr(std::is_invocable_v<decltype(Data), Type &>) {
+            if constexpr(stl::is_invocable_v<decltype(Data), Type &>) {
                 if(auto *clazz = instance->try_cast<Type>(); clazz) {
                 if(auto *clazz = instance->try_cast<Type>(); clazz) {
                     return meta_dispatch<Policy>(instance->context(), std::invoke(Data, *clazz));
                     return meta_dispatch<Policy>(instance->context(), std::invoke(Data, *clazz));
                 }
                 }
             }
             }
 
 
-            if constexpr(std::is_invocable_v<decltype(Data), const Type &>) {
+            if constexpr(stl::is_invocable_v<decltype(Data), const Type &>) {
                 if(auto *fallback = instance->try_cast<const Type>(); fallback) {
                 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(), std::invoke(Data, *fallback));
                 }
                 }

+ 2 - 2
src/entt/signal/sigh.hpp

@@ -193,10 +193,10 @@ public:
     template<typename Func>
     template<typename Func>
     void collect(Func func, Args... args) const {
     void collect(Func func, Args... args) const {
         for(auto pos = calls.size(); pos; --pos) {
         for(auto pos = calls.size(); pos; --pos) {
-            if constexpr(stl::is_void_v<Ret> || !std::is_invocable_v<Func, Ret>) {
+            if constexpr(stl::is_void_v<Ret> || !stl::is_invocable_v<Func, Ret>) {
                 calls[pos - 1u](args...);
                 calls[pos - 1u](args...);
 
 
-                if constexpr(std::is_invocable_r_v<bool, Func>) {
+                if constexpr(stl::is_invocable_r_v<bool, Func>) {
                     if(func()) {
                     if(func()) {
                         break;
                         break;
                     }
                     }

+ 3 - 0
src/entt/stl/type_traits.hpp

@@ -18,7 +18,10 @@ using std::is_copy_assignable_v;
 using std::is_copy_constructible_v;
 using std::is_copy_constructible_v;
 using std::is_default_constructible_v;
 using std::is_default_constructible_v;
 using std::is_function_v;
 using std::is_function_v;
+using std::is_invocable;
+using std::is_invocable_r;
 using std::is_invocable_r_v;
 using std::is_invocable_r_v;
+using std::is_invocable_v;
 using std::is_lvalue_reference_v;
 using std::is_lvalue_reference_v;
 using std::is_member_object_pointer_v;
 using std::is_member_object_pointer_v;
 using std::is_move_assignable_v;
 using std::is_move_assignable_v;