Преглед на файлове

type_traits: minor changes

Michele Caini преди 5 години
родител
ревизия
6c9fab7da1
променени са 2 файла, в които са добавени 16 реда и са изтрити 4 реда
  1. 3 2
      docs/md/core.md
  2. 13 2
      src/entt/core/type_traits.hpp

+ 3 - 2
docs/md/core.md

@@ -409,14 +409,15 @@ Moreover, users are also provided with `std::apply`, a tool for combining
 invocable elements and tuples of arguments.
 
 It would therefore be a good idea to have a variant of `std::is_invocable` that
-also accepts its arguments in the form of a tuple, to complete the offer:
+also accepts its arguments in the form of a tuple-like type, so as to complete
+the offer:
 
 ```cpp
 constexpr bool result = entt::is_applicable<Func, std::tuple<a_type, another_type>>;
 ```
 
 This trait is built on top of `std::is_invocable` and does nothing but unpack a
-tuple and simplify the code at the call site.
+tuple-like type and simplify the code at the call site.
 
 ### Constness as
 

+ 13 - 2
src/entt/core/type_traits.hpp

@@ -261,10 +261,21 @@ struct is_applicable: std::false_type {};
 /**
  * @copybrief is_applicable
  * @tparam Func A valid function type.
+ * @tparam Tuple Tuple-like type.
  * @tparam Args The list of arguments to use to probe the function type.
  */
-template<typename Func, typename... Args>
-struct is_applicable<Func, std::tuple<Args...>>: std::is_invocable<Func, Args...> {};
+template<typename Func, template<typename...> class Tuple, typename... Args>
+struct is_applicable<Func, Tuple<Args...>>: std::is_invocable<Func, Args...> {};
+
+
+/**
+* @copybrief is_applicable
+* @tparam Func A valid function type.
+* @tparam Tuple Tuple-like type.
+* @tparam Args The list of arguments to use to probe the function type.
+*/
+template<typename Func, template<typename...> class Tuple, typename... Args>
+struct is_applicable<Func, const Tuple<Args...>>: std::is_invocable<Func, Args...> {};
 
 
 /**