From patchwork Mon Oct 26 19:52:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 10264 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 7E7D5C3B5C for ; Mon, 26 Oct 2020 19:53:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 699206206A; Mon, 26 Oct 2020 20:53:02 +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="wfJPrqhs"; 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 A29B862061 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 3699C99A for ; Mon, 26 Oct 2020 20:53:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1603741980; bh=MrO6OGgCI+mXrOCH279xYT2MX2jADb78wPiScIMZZP4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=wfJPrqhs/Rc1Ch+GKSOAX4lo4NpA9BwhCS0Uqx4qt45Ya0aaY6YxWrOCm/HCNrwd6 n+VRgEtQQ3rUfy0ksMz5VoQQKhfjIxT28eXkMSLDTXGioIWmT9jIUWK9oAr5EWI81z V0b95+PJQbqLIGzv6eeOdnPPAUIfx0MKPzW06NFg= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 26 Oct 2020 21:52:09 +0200 Message-Id: <20201026195209.16748-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201026195209.16748-1-laurent.pinchart@ideasonboard.com> References: <20201026195209.16748-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/2] libcamera: span: Provide and use helper variable templates 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" Following the C++17 practice, provide is_array_v and is_span_v helper variable templates as shorter versions of is_array::value and is_span::value, and use them through the code. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- include/libcamera/controls.h | 12 ++++++------ include/libcamera/span.h | 22 ++++++++++++++-------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index dc549a92f975..3634dc431618 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -96,7 +96,7 @@ public: ControlValue(); #ifndef __DOXYGEN__ - template::value && + template && details::control_type::value && !std::is_same_v>, std::nullptr_t> = nullptr> @@ -107,7 +107,7 @@ public: &value, 1, sizeof(T)); } - template::value || + template || std::is_same_v>, std::nullptr_t> = nullptr> #else @@ -141,7 +141,7 @@ public: } #ifndef __DOXYGEN__ - template::value && + template && !std::is_same_v>, std::nullptr_t> = nullptr> T get() const @@ -152,7 +152,7 @@ public: return *reinterpret_cast(data().data()); } - template::value || + template || std::is_same_v>, std::nullptr_t> = nullptr> #else @@ -169,7 +169,7 @@ public: } #ifndef __DOXYGEN__ - template::value && + template && !std::is_same_v>, std::nullptr_t> = nullptr> void set(const T &value) @@ -178,7 +178,7 @@ public: reinterpret_cast(&value), 1, sizeof(T)); } - template::value || + template || std::is_same_v>, std::nullptr_t> = nullptr> #else diff --git a/include/libcamera/span.h b/include/libcamera/span.h index d720adb81f89..e7ffef1255d4 100644 --- a/include/libcamera/span.h +++ b/include/libcamera/span.h @@ -31,6 +31,9 @@ template struct is_array> : public std::true_type { }; +template +inline constexpr bool is_array_v = is_array::value; + template struct is_span : public std::false_type { }; @@ -39,6 +42,9 @@ template struct is_span> : public std::true_type { }; +template +inline constexpr bool is_span_v = is_span::value; + } /* namespace details */ namespace utils { @@ -155,8 +161,8 @@ public: template explicit constexpr Span(Container &cont, - std::enable_if_t::value && - !details::is_array::value && + std::enable_if_t && + !details::is_array_v && !std::is_array_v && std::is_convertible_v (*)[], element_type (*)[]>, @@ -167,8 +173,8 @@ public: template explicit constexpr Span(const Container &cont, - std::enable_if_t::value && - !details::is_array::value && + std::enable_if_t && + !details::is_array_v && !std::is_array_v && std::is_convertible_v (*)[], element_type (*)[]>, @@ -317,8 +323,8 @@ public: template constexpr Span(Container &cont, - std::enable_if_t::value && - !details::is_array::value && + std::enable_if_t && + !details::is_array_v && !std::is_array_v && std::is_convertible_v (*)[], element_type (*)[]>, @@ -329,8 +335,8 @@ public: template constexpr Span(const Container &cont, - std::enable_if_t::value && - !details::is_array::value && + std::enable_if_t && + !details::is_array_v && !std::is_array_v && std::is_convertible_v (*)[], element_type (*)[]>,