From 6c9fab7da1c4412b8cc4285eb209da7e5313473d Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Thu, 26 Nov 2020 10:23:09 +0100 Subject: [PATCH] type_traits: minor changes --- docs/md/core.md | 5 +++-- src/entt/core/type_traits.hpp | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/docs/md/core.md b/docs/md/core.md index 42b2bc109..7600f2b72 100644 --- a/docs/md/core.md +++ b/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>; ``` 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 diff --git a/src/entt/core/type_traits.hpp b/src/entt/core/type_traits.hpp index 51c4fd131..de7970be8 100644 --- a/src/entt/core/type_traits.hpp +++ b/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 -struct is_applicable>: std::is_invocable {}; +template class Tuple, typename... Args> +struct is_applicable>: std::is_invocable {}; + + +/** +* @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 class Tuple, typename... Args> +struct is_applicable>: std::is_invocable {}; /**