From 7f318327e57122c7f49bdef9915153f6956a5c7d Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Thu, 20 Jan 2022 14:02:34 +0100 Subject: [PATCH] QtConcurrent: use variable templates for compile-time checks Noticed during the API review. Pick-to: 6.3 6.2 Task-number: QTBUG-99883 Change-Id: I19571343a0cf0609beae2422ef1f69f7a34eb9ac Reviewed-by: Fabian Kosmale --- src/concurrent/qtconcurrentfilter.h | 4 ++-- src/concurrent/qtconcurrentfunctionwrappers.h | 19 ++++++------------- src/concurrent/qtconcurrentmap.h | 4 ++-- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/concurrent/qtconcurrentfilter.h b/src/concurrent/qtconcurrentfilter.h index dce4f35db6..2fdc8f9d0f 100644 --- a/src/concurrent/qtconcurrentfilter.h +++ b/src/concurrent/qtconcurrentfilter.h @@ -333,7 +333,7 @@ QFuture filteredReduced(QThreadPool *pool, } template ::value, int> = 0, + std::enable_if_t, int> = 0, typename ResultType = typename QtPrivate::ReduceResultTypeHelper::type, typename InitialValueType, std::enable_if_t, int> = 0> @@ -673,7 +673,7 @@ ResultType blockingFilteredReduced(QThreadPool *pool, } template ::value, int> = 0, + std::enable_if_t, int> = 0, typename ResultType = typename QtPrivate::ReduceResultTypeHelper::type, typename InitialValueType, std::enable_if_t, int> = 0> diff --git a/src/concurrent/qtconcurrentfunctionwrappers.h b/src/concurrent/qtconcurrentfunctionwrappers.h index 08966115d6..e9154070bc 100644 --- a/src/concurrent/qtconcurrentfunctionwrappers.h +++ b/src/concurrent/qtconcurrentfunctionwrappers.h @@ -142,24 +142,17 @@ struct ReduceResultType }; template -struct hasCallOperator : std::false_type -{ -}; +inline constexpr bool hasCallOperator_v = false; template -struct hasCallOperator> : std::true_type -{ -}; +inline constexpr bool hasCallOperator_v> = true; template -struct isIterator : std::false_type -{ -}; +inline constexpr bool isIterator_v = false; template -struct isIterator::value_type>> : std::true_type -{ -}; +inline constexpr bool isIterator_v::value_type>> = + true; template using isInvocable = std::is_invocable::value_type>; @@ -180,7 +173,7 @@ struct ReduceResultTypeHelper struct ReduceResultTypeHelper>> - && hasCallOperator>::value>> + && hasCallOperator_v>>> { using type = std::decay_t::First>; }; diff --git a/src/concurrent/qtconcurrentmap.h b/src/concurrent/qtconcurrentmap.h index 3e20f8b4dc..64e9fe938c 100644 --- a/src/concurrent/qtconcurrentmap.h +++ b/src/concurrent/qtconcurrentmap.h @@ -352,7 +352,7 @@ template #else template::value, int> = 0, + std::enable_if_t, int> = 0, typename ResultType = typename QtPrivate::ReduceResultTypeHelper::type, typename InitialValueType, std::enable_if_t, int> = 0> @@ -739,7 +739,7 @@ template #else template ::value, int> = 0, + std::enable_if_t, int> = 0, typename ResultType = typename QtPrivate::ReduceResultTypeHelper::type, typename InitialValueType, std::enable_if_t, int> = 0>