From patchwork Mon Jan 20 00:24:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2693 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 E9DAA607C4 for ; Mon, 20 Jan 2020 01:24:44 +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 8A625529 for ; Mon, 20 Jan 2020 01:24:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1579479884; bh=8HAk4qCr0p0EA2DP7p4x/yStMqE64E+iuD7/sZsNGtE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=eXAT2eybpvGP29QXxe+hot9TFWuNntOYAN5FBjlrL3pWUHKw6GzA+Z+XVDGGM/1cy nQAlfxTMJG0SrjcuYMxLna3wD8Y0cJADMpaY+oFcZsJP/1Eca0CRoTT7wnty/OL7cX DbKRm0TpU+8CSrZ7XqnP01RvmYMTYp9PNbqJZeso= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 20 Jan 2020 02:24:24 +0200 Message-Id: <20200120002437.6633-7-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200120002437.6633-1-laurent.pinchart@ideasonboard.com> References: <20200120002437.6633-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 06/19] libcamera: bound_method: Use std::index_sequence 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: Mon, 20 Jan 2020 00:24:46 -0000 Now that we're using C++-14, replace the manual implementation of std::integer_sequence with std::index_sequence, a specialization of std::integer_sequence with the integer type equal to std::size_t. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Niklas Söderlund --- include/libcamera/bound_method.h | 38 +++++++++----------------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/include/libcamera/bound_method.h b/include/libcamera/bound_method.h index ca501493bce2..7ffd2e426e18 100644 --- a/include/libcamera/bound_method.h +++ b/include/libcamera/bound_method.h @@ -10,6 +10,7 @@ #include #include #include +#include namespace libcamera { @@ -71,25 +72,6 @@ public: virtual void invokePack(BoundMethodPackBase *pack) = 0; protected: -#ifndef __DOXYGEN__ - /* - * This is a cheap partial implementation of std::integer_sequence<> - * from C++14. - */ - template - struct sequence { - }; - - template - struct generator : generator { - }; - - template - struct generator<0, S...> { - typedef sequence type; - }; -#endif - bool activatePack(std::shared_ptr pack, bool deleteMethod); @@ -107,11 +89,11 @@ public: using PackType = BoundMethodPack; private: - template - void invokePack(BoundMethodPackBase *pack, BoundMethodBase::sequence) + template + void invokePack(BoundMethodPackBase *pack, std::index_sequence) { PackType *args = static_cast(pack); - args->ret_ = invoke(std::get(args->args_)...); + args->ret_ = invoke(std::get(args->args_)...); } public: @@ -120,7 +102,7 @@ public: void invokePack(BoundMethodPackBase *pack) override { - invokePack(pack, typename BoundMethodBase::generator::type()); + invokePack(pack, std::make_index_sequence{}); } virtual R activate(Args... args, bool deleteMethod = false) = 0; @@ -134,12 +116,12 @@ public: using PackType = BoundMethodPack; private: - template - void invokePack(BoundMethodPackBase *pack, BoundMethodBase::sequence) + template + void invokePack(BoundMethodPackBase *pack, std::index_sequence) { - /* args is effectively unused when the sequence S is empty. */ + /* args is effectively unused when the sequence I is empty. */ PackType *args [[gnu::unused]] = static_cast(pack); - invoke(std::get(args->args_)...); + invoke(std::get(args->args_)...); } public: @@ -148,7 +130,7 @@ public: void invokePack(BoundMethodPackBase *pack) override { - invokePack(pack, typename BoundMethodBase::generator::type()); + invokePack(pack, std::make_index_sequence{}); } virtual void activate(Args... args, bool deleteMethod = false) = 0;