From patchwork Thu Dec 31 15:47:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Michel Hautbois X-Patchwork-Id: 10793 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 BDC03C0F1C for ; Thu, 31 Dec 2020 15:47:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4E52D615B2; Thu, 31 Dec 2020 16:47:15 +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="b1oJkEg6"; 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 D74796031B for ; Thu, 31 Dec 2020 16:47:13 +0100 (CET) Received: from localhost.localdomain (unknown [IPv6:2a01:e0a:169:7140:c855:241b:6286:4626]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 60CCD52F; Thu, 31 Dec 2020 16:47:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1609429633; bh=Kf2/mOWQCWRgJMYWzkZXM3J2voLeWVZI0lXA4HPw5gQ=; h=From:To:Cc:Subject:Date:From; b=b1oJkEg6lviVkkhtcqE4Pwj8FmABq2yIZ6fH0dj3fzk8Az6BytrNL0yfmOVdNY+MP o0ixK6T1nbNnj7fN5JFUnnhVH3tr0RkC4+5LNb+q375aABlw8IDNCsilV6j3jr6jeo dNhQKLUYUMU5R0x1a6Rfdk0SNG+628JPNCruxsp4= From: Jean-Michel Hautbois To: libcamera-devel@lists.libcamera.org Date: Thu, 31 Dec 2020 16:47:10 +0100 Message-Id: <20201231154711.207852-1-jeanmichel.hautbois@ideasonboard.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] libcamera: revert C++17 specific code for public API 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" Some applications may not be compliant with C++17 (Chromium, as an example). Keep the C++17 features for libcamera internals, and C++14 compliance for public API. This reverts commits 8e42c2feb7ff7c350ffbbf97dd963dfd54e21faa and 6cbdc2859963e17bc897a4022f1d68170477d888. Signed-off-by: Jean-Michel Hautbois --- include/libcamera/bound_method.h | 2 +- include/libcamera/controls.h | 24 +++++------ include/libcamera/object.h | 2 +- include/libcamera/signal.h | 4 +- include/libcamera/span.h | 70 +++++++++++++++----------------- 5 files changed, 48 insertions(+), 54 deletions(-) diff --git a/include/libcamera/bound_method.h b/include/libcamera/bound_method.h index feac51da..95a95653 100644 --- a/include/libcamera/bound_method.h +++ b/include/libcamera/bound_method.h @@ -63,7 +63,7 @@ public: } virtual ~BoundMethodBase() = default; - template> * = nullptr> + template::value> * = 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 3634dc43..3b7f3347 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -96,9 +96,9 @@ public: ControlValue(); #ifndef __DOXYGEN__ - template && + template::value && details::control_type::value && - !std::is_same_v>, + !std::is_same>::value, std::nullptr_t> = nullptr> ControlValue(const T &value) : type_(ControlTypeNone), numElements_(0) @@ -107,8 +107,8 @@ public: &value, 1, sizeof(T)); } - template || - std::is_same_v>, + template::value || + std::is_same>::value, std::nullptr_t> = nullptr> #else template @@ -141,8 +141,8 @@ public: } #ifndef __DOXYGEN__ - template && - !std::is_same_v>, + template::value && + !std::is_same>::value, std::nullptr_t> = nullptr> T get() const { @@ -152,8 +152,8 @@ public: return *reinterpret_cast(data().data()); } - template || - std::is_same_v>, + template::value || + std::is_same>::value, std::nullptr_t> = nullptr> #else template @@ -169,8 +169,8 @@ public: } #ifndef __DOXYGEN__ - template && - !std::is_same_v>, + template::value && + !std::is_same>::value, std::nullptr_t> = nullptr> void set(const T &value) { @@ -178,8 +178,8 @@ public: reinterpret_cast(&value), 1, sizeof(T)); } - template || - std::is_same_v>, + template::value || + std::is_same>::value, std::nullptr_t> = nullptr> #else template diff --git a/include/libcamera/object.h b/include/libcamera/object.h index 423208db..a1882f05 100644 --- a/include/libcamera/object.h +++ b/include/libcamera/object.h @@ -32,7 +32,7 @@ public: void postMessage(std::unique_ptr msg); template> * = nullptr> + typename std::enable_if_t::value> * = nullptr> R invokeMethod(R (T::*func)(FuncArgs...), ConnectionType type, Args... args) { diff --git a/include/libcamera/signal.h b/include/libcamera/signal.h index 46d917d5..5bcd7a77 100644 --- a/include/libcamera/signal.h +++ b/include/libcamera/signal.h @@ -44,7 +44,7 @@ public: } #ifndef __DOXYGEN__ - template> * = nullptr> + template::value> * = 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> * = nullptr> + template::value> * = nullptr> #else template #endif diff --git a/include/libcamera/span.h b/include/libcamera/span.h index e7ffef12..91e9f974 100644 --- a/include/libcamera/span.h +++ b/include/libcamera/span.h @@ -31,9 +31,6 @@ 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 { }; @@ -42,9 +39,6 @@ template struct is_span> : public std::true_type { }; -template -inline constexpr bool is_span_v = is_span::value; - } /* namespace details */ namespace utils { @@ -131,8 +125,8 @@ public: template constexpr Span(element_type (&arr)[N], - std::enable_if_t (*)[], - element_type (*)[]> && + std::enable_if_t (*)[], + element_type (*)[]>::value && N == Extent, std::nullptr_t> = nullptr) noexcept : data_(arr) @@ -141,8 +135,8 @@ public: template constexpr Span(std::array &arr, - std::enable_if_t (*)[], - element_type (*)[]> && + std::enable_if_t (*)[], + element_type (*)[]>::value && N == Extent, std::nullptr_t> = nullptr) noexcept : data_(arr.data()) @@ -151,8 +145,8 @@ public: template constexpr Span(const std::array &arr, - std::enable_if_t (*)[], - element_type (*)[]> && + std::enable_if_t (*)[], + element_type (*)[]>::value && N == Extent, std::nullptr_t> = nullptr) noexcept : data_(arr.data()) @@ -161,11 +155,11 @@ public: template explicit constexpr Span(Container &cont, - std::enable_if_t && - !details::is_array_v && - !std::is_array_v && - std::is_convertible_v (*)[], - element_type (*)[]>, + std::enable_if_t::value && + !details::is_array::value && + !std::is_array::value && + std::is_convertible (*)[], + element_type (*)[]>::value, std::nullptr_t> = nullptr) : data_(utils::data(cont)) { @@ -173,11 +167,11 @@ public: template explicit constexpr Span(const Container &cont, - std::enable_if_t && - !details::is_array_v && - !std::is_array_v && - std::is_convertible_v (*)[], - element_type (*)[]>, + std::enable_if_t::value && + !details::is_array::value && + !std::is_array::value && + std::is_convertible (*)[], + element_type (*)[]>::value, std::nullptr_t> = nullptr) : data_(utils::data(cont)) { @@ -186,7 +180,7 @@ public: template explicit constexpr Span(const Span &s, - std::enable_if_t && + std::enable_if_t::value && N == Extent, std::nullptr_t> = nullptr) noexcept : data_(s.data()) @@ -299,8 +293,8 @@ public: template constexpr Span(element_type (&arr)[N], - std::enable_if_t (*)[], - element_type (*)[]>, + std::enable_if_t (*)[], + element_type (*)[]>::value, std::nullptr_t> = nullptr) noexcept : data_(arr), size_(N) { @@ -308,8 +302,8 @@ public: template constexpr Span(std::array &arr, - std::enable_if_t (*)[], - element_type (*)[]>, + std::enable_if_t (*)[], + element_type (*)[]>::value, std::nullptr_t> = nullptr) noexcept : data_(utils::data(arr)), size_(N) { @@ -323,11 +317,11 @@ public: template constexpr Span(Container &cont, - std::enable_if_t && - !details::is_array_v && - !std::is_array_v && - std::is_convertible_v (*)[], - element_type (*)[]>, + std::enable_if_t::value && + !details::is_array::value && + !std::is_array::value && + std::is_convertible (*)[], + element_type (*)[]>::value, std::nullptr_t> = nullptr) : data_(utils::data(cont)), size_(utils::size(cont)) { @@ -335,11 +329,11 @@ public: template constexpr Span(const Container &cont, - std::enable_if_t && - !details::is_array_v && - !std::is_array_v && - std::is_convertible_v (*)[], - element_type (*)[]>, + std::enable_if_t::value && + !details::is_array::value && + !std::is_array::value && + std::is_convertible (*)[], + element_type (*)[]>::value, std::nullptr_t> = nullptr) : data_(utils::data(cont)), size_(utils::size(cont)) { @@ -347,7 +341,7 @@ public: template constexpr Span(const Span &s, - std::enable_if_t, + std::enable_if_t::value, std::nullptr_t> = nullptr) noexcept : data_(s.data()), size_(s.size()) {