From patchwork Mon Oct 26 19:52:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 10263 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 991DCC3B5C for ; Mon, 26 Oct 2020 19:53:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E6A8462067; Mon, 26 Oct 2020 20:53:01 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="moauUd8K"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5F40B60350 for ; Mon, 26 Oct 2020 20:53:00 +0100 (CET) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D9AB5527 for ; Mon, 26 Oct 2020 20:52:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1603741980; bh=Iz5L6q5eGV5XMDwUcIW2q1bVKWYgqyoE9ARr/nweGBs=; h=From:To:Subject:Date:From; b=moauUd8KuR/fM85H7Qe11oAbsRAplXq/MA4/WadC7dDz7gOeiaoRGguew7XjRaemb AbNzmCNtUL6AhsfTWt7Daqu45hbyFFBTyjXDqAXK+Lc6UjfxEIoBMqNRDlpXB2fGFW +4K1Ybdm710iHCaYZJPR+/nAe/qlstSoF42FkVfQ= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 26 Oct 2020 21:52:08 +0200 Message-Id: <20201026195209.16748-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/2] libcamera: Use helper variable template for type traits X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" C++17 introduces helper variable templates for type traits, allowing shortening std::is_foo::value to std::is_foo_v. Use them through the code base. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- include/libcamera/bound_method.h | 2 +- include/libcamera/controls.h | 12 ++++---- include/libcamera/object.h | 2 +- include/libcamera/signal.h | 4 +-- include/libcamera/span.h | 48 ++++++++++++++++---------------- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/include/libcamera/bound_method.h b/include/libcamera/bound_method.h index 95a956530877..feac51dac527 100644 --- a/include/libcamera/bound_method.h +++ b/include/libcamera/bound_method.h @@ -63,7 +63,7 @@ public: } virtual ~BoundMethodBase() = default; - template::value> * = nullptr> + template> * = nullptr> bool match(T *obj) { return obj == obj_; } bool match(Object *object) { return object == object_; } diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 3b7f3347761e..dc549a92f975 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -98,7 +98,7 @@ public: #ifndef __DOXYGEN__ template::value && details::control_type::value && - !std::is_same>::value, + !std::is_same_v>, std::nullptr_t> = nullptr> ControlValue(const T &value) : type_(ControlTypeNone), numElements_(0) @@ -108,7 +108,7 @@ public: } template::value || - std::is_same>::value, + std::is_same_v>, std::nullptr_t> = nullptr> #else template @@ -142,7 +142,7 @@ public: #ifndef __DOXYGEN__ template::value && - !std::is_same>::value, + !std::is_same_v>, std::nullptr_t> = nullptr> T get() const { @@ -153,7 +153,7 @@ public: } template::value || - std::is_same>::value, + std::is_same_v>, std::nullptr_t> = nullptr> #else template @@ -170,7 +170,7 @@ public: #ifndef __DOXYGEN__ template::value && - !std::is_same>::value, + !std::is_same_v>, std::nullptr_t> = nullptr> void set(const T &value) { @@ -179,7 +179,7 @@ public: } template::value || - std::is_same>::value, + std::is_same_v>, std::nullptr_t> = nullptr> #else template diff --git a/include/libcamera/object.h b/include/libcamera/object.h index a1882f05fb77..423208db24bd 100644 --- a/include/libcamera/object.h +++ b/include/libcamera/object.h @@ -32,7 +32,7 @@ public: void postMessage(std::unique_ptr msg); template::value> * = nullptr> + typename std::enable_if_t> * = nullptr> R invokeMethod(R (T::*func)(FuncArgs...), ConnectionType type, Args... args) { diff --git a/include/libcamera/signal.h b/include/libcamera/signal.h index 5bcd7a77c5f1..46d917d5f582 100644 --- a/include/libcamera/signal.h +++ b/include/libcamera/signal.h @@ -44,7 +44,7 @@ public: } #ifndef __DOXYGEN__ - template::value> * = nullptr> + template> * = nullptr> void connect(T *obj, R (T::*func)(Args...), ConnectionType type = ConnectionTypeAuto) { @@ -52,7 +52,7 @@ public: SignalBase::connect(new BoundMethodMember(obj, object, func, type)); } - template::value> * = nullptr> + template> * = nullptr> #else template #endif diff --git a/include/libcamera/span.h b/include/libcamera/span.h index 91e9f974cc58..d720adb81f89 100644 --- a/include/libcamera/span.h +++ b/include/libcamera/span.h @@ -125,8 +125,8 @@ public: template constexpr Span(element_type (&arr)[N], - std::enable_if_t (*)[], - element_type (*)[]>::value && + std::enable_if_t (*)[], + element_type (*)[]> && N == Extent, std::nullptr_t> = nullptr) noexcept : data_(arr) @@ -135,8 +135,8 @@ public: template constexpr Span(std::array &arr, - std::enable_if_t (*)[], - element_type (*)[]>::value && + std::enable_if_t (*)[], + element_type (*)[]> && N == Extent, std::nullptr_t> = nullptr) noexcept : data_(arr.data()) @@ -145,8 +145,8 @@ public: template constexpr Span(const std::array &arr, - std::enable_if_t (*)[], - element_type (*)[]>::value && + std::enable_if_t (*)[], + element_type (*)[]> && N == Extent, std::nullptr_t> = nullptr) noexcept : data_(arr.data()) @@ -157,9 +157,9 @@ public: explicit constexpr Span(Container &cont, std::enable_if_t::value && !details::is_array::value && - !std::is_array::value && - std::is_convertible (*)[], - element_type (*)[]>::value, + !std::is_array_v && + std::is_convertible_v (*)[], + element_type (*)[]>, std::nullptr_t> = nullptr) : data_(utils::data(cont)) { @@ -169,9 +169,9 @@ public: explicit constexpr Span(const Container &cont, std::enable_if_t::value && !details::is_array::value && - !std::is_array::value && - std::is_convertible (*)[], - element_type (*)[]>::value, + !std::is_array_v && + std::is_convertible_v (*)[], + element_type (*)[]>, std::nullptr_t> = nullptr) : data_(utils::data(cont)) { @@ -180,7 +180,7 @@ public: template explicit constexpr Span(const Span &s, - std::enable_if_t::value && + std::enable_if_t && N == Extent, std::nullptr_t> = nullptr) noexcept : data_(s.data()) @@ -293,8 +293,8 @@ public: template constexpr Span(element_type (&arr)[N], - std::enable_if_t (*)[], - element_type (*)[]>::value, + std::enable_if_t (*)[], + element_type (*)[]>, std::nullptr_t> = nullptr) noexcept : data_(arr), size_(N) { @@ -302,8 +302,8 @@ public: template constexpr Span(std::array &arr, - std::enable_if_t (*)[], - element_type (*)[]>::value, + std::enable_if_t (*)[], + element_type (*)[]>, std::nullptr_t> = nullptr) noexcept : data_(utils::data(arr)), size_(N) { @@ -319,9 +319,9 @@ public: constexpr Span(Container &cont, std::enable_if_t::value && !details::is_array::value && - !std::is_array::value && - std::is_convertible (*)[], - element_type (*)[]>::value, + !std::is_array_v && + std::is_convertible_v (*)[], + element_type (*)[]>, std::nullptr_t> = nullptr) : data_(utils::data(cont)), size_(utils::size(cont)) { @@ -331,9 +331,9 @@ public: constexpr Span(const Container &cont, std::enable_if_t::value && !details::is_array::value && - !std::is_array::value && - std::is_convertible (*)[], - element_type (*)[]>::value, + !std::is_array_v && + std::is_convertible_v (*)[], + element_type (*)[]>, std::nullptr_t> = nullptr) : data_(utils::data(cont)), size_(utils::size(cont)) { @@ -341,7 +341,7 @@ public: template constexpr Span(const Span &s, - std::enable_if_t::value, + std::enable_if_t, std::nullptr_t> = nullptr) noexcept : data_(s.data()), size_(s.size()) {