From patchwork Sun Feb 16 00:13:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2834 Return-Path: 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 A81F761020 for ; Sun, 16 Feb 2020 01:13:28 +0100 (CET) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0B32B2D2 for ; Sun, 16 Feb 2020 01:13:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1581812008; bh=FETkKt154A4fE5e9r0uP5Jg5qXfBuT08clnz0Seb/b4=; h=From:To:Subject:Date:From; b=ineqiG0g1omOaAup9m0c9tbZ6akaY7snpxwXsK0De/IGo6lcMEWtSX5nntp3NUU6u dNwhCFc3Pvwnh16g5HzHf4j2oI8H4hp/uYROZbzyB7nHuRG4ctJXI6n/qg9yw8Jefk ry2DnckTeHkao7fR4PAaAvnpW/pISLXqiYq8Uojo= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sun, 16 Feb 2020 02:13:04 +0200 Message-Id: <20200216001304.5167-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] libcamera: Use C++14 std::*_t 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: , X-List-Received-Date: Sun, 16 Feb 2020 00:13:28 -0000 C++14 introduced useful type traits helpers named std::*_t as aliases to std::*<...>::type. Use them to simplify the code. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- include/libcamera/bound_method.h | 6 +++--- include/libcamera/object.h | 2 +- include/libcamera/signal.h | 4 ++-- src/libcamera/ipa_module.cpp | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/libcamera/bound_method.h b/include/libcamera/bound_method.h index 7ffd2e426e18..983bb5cbbad0 100644 --- a/include/libcamera/bound_method.h +++ b/include/libcamera/bound_method.h @@ -38,7 +38,7 @@ public: { } - std::tuple::type...> args_; + std::tuple...> args_; R ret_; }; @@ -51,7 +51,7 @@ public: { } - std::tuple::type...> args_; + std::tuple...> args_; }; class BoundMethodBase @@ -63,7 +63,7 @@ public: } virtual ~BoundMethodBase() {} - template::value>::type * = nullptr> + template::value> * = nullptr> bool match(T *obj) { return obj == obj_; } bool match(Object *object) { return object == object_; } diff --git a/include/libcamera/object.h b/include/libcamera/object.h index 4d16f3f2b610..9a3dd0702d39 100644 --- a/include/libcamera/object.h +++ b/include/libcamera/object.h @@ -30,7 +30,7 @@ public: void postMessage(std::unique_ptr msg); template::value>::type * = 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 c13bb30f0636..ed30eb559127 100644 --- a/include/libcamera/signal.h +++ b/include/libcamera/signal.h @@ -45,7 +45,7 @@ public: } #ifndef __DOXYGEN__ - template::value>::type * = nullptr> + template::value> * = nullptr> void connect(T *obj, R (T::*func)(Args...), ConnectionType type = ConnectionTypeAuto) { @@ -53,7 +53,7 @@ public: SignalBase::connect(new BoundMethodMember(obj, object, func, type)); } - template::value>::type * = nullptr> + template::value> * = nullptr> #else template #endif diff --git a/src/libcamera/ipa_module.cpp b/src/libcamera/ipa_module.cpp index de65525b8319..a01d0757ff8f 100644 --- a/src/libcamera/ipa_module.cpp +++ b/src/libcamera/ipa_module.cpp @@ -42,20 +42,20 @@ LOG_DEFINE_CATEGORY(IPAModule) namespace { template -typename std::remove_extent::type *elfPointer(void *map, off_t offset, - size_t fileSize, size_t objSize) +typename std::remove_extent_t *elfPointer(void *map, off_t offset, + size_t fileSize, size_t objSize) { size_t size = offset + objSize; if (size > fileSize || size < objSize) return nullptr; - return reinterpret_cast::type *> + return reinterpret_cast *> (static_cast(map) + offset); } template -typename std::remove_extent::type *elfPointer(void *map, off_t offset, - size_t fileSize) +typename std::remove_extent_t *elfPointer(void *map, off_t offset, + size_t fileSize) { return elfPointer(map, offset, fileSize, sizeof(T)); }