From patchwork Fri Aug 27 02:38:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13524 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 ADDA8C3242 for ; Fri, 27 Aug 2021 02:38:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 56CE86894D; Fri, 27 Aug 2021 04:38:51 +0200 (CEST) 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="Dq7xO4El"; 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 DE3B968932 for ; Fri, 27 Aug 2021 04:38:46 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 820795A1 for ; Fri, 27 Aug 2021 04:38:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1630031926; bh=/CT9LXBbuiJs722tlb64o45gG2f7PBV52Oe+OkIU0Tk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Dq7xO4ElalIJoTnFQqDg1XfiYBDdoPSAhRWbyu06qTU9+ocMBzhEJoyPgJ2NWfboR jCESsTh7SWBoNTiKslWAhUHViYt4SZvDfUPkq/5TQLM0qf79ArE/fw2ZBXzehrZ60D RINDkZ+rc314itXEM/bgETFS+8s0NQrPQxOO1EmY= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 27 Aug 2021 05:38:26 +0300 Message-Id: <20210827023829.5871-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210827023829.5871-1-laurent.pinchart@ideasonboard.com> References: <20210827023829.5871-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 3/6] libcamera: base: bound_method: Remove BoundMethodArgs specialization 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" The BoundMethodArgs specialization for the void return type is only needed to avoid accessing the ret_ member variable that is lacking from the corresponding BoundMethodPack specialization. As the member variable is only accessed in a single function, instead of specializing the whole class we can use SFINAE to select between two different implementations of the function. Signed-off-by: Laurent Pinchart Reviewed-by: Umang Jain --- include/libcamera/base/bound_method.h | 34 +++++++-------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/include/libcamera/base/bound_method.h b/include/libcamera/base/bound_method.h index 9c212f1ecc3a..76ce8017e721 100644 --- a/include/libcamera/base/bound_method.h +++ b/include/libcamera/base/bound_method.h @@ -98,35 +98,17 @@ public: using PackType = BoundMethodPack; private: - template - void invokePack(BoundMethodPackBase *pack, std::index_sequence) + template + std::enable_if_t::value, void> + invokePack(BoundMethodPackBase *pack, std::index_sequence) { PackType *args = static_cast(pack); args->ret_ = invoke(std::get(args->args_)...); } -public: - BoundMethodArgs(void *obj, Object *object, ConnectionType type) - : BoundMethodBase(obj, object, type) {} - - void invokePack(BoundMethodPackBase *pack) override - { - invokePack(pack, std::make_index_sequence{}); - } - - virtual R activate(Args... args, bool deleteMethod = false) = 0; - virtual R invoke(Args... args) = 0; -}; - -template -class BoundMethodArgs : public BoundMethodBase -{ -public: - using PackType = BoundMethodPack; - -private: - template - void invokePack(BoundMethodPackBase *pack, std::index_sequence) + template + std::enable_if_t::value, void> + invokePack(BoundMethodPackBase *pack, std::index_sequence) { /* args is effectively unused when the sequence I is empty. */ PackType *args [[gnu::unused]] = static_cast(pack); @@ -142,8 +124,8 @@ public: invokePack(pack, std::make_index_sequence{}); } - virtual void activate(Args... args, bool deleteMethod = false) = 0; - virtual void invoke(Args... args) = 0; + virtual R activate(Args... args, bool deleteMethod = false) = 0; + virtual R invoke(Args... args) = 0; }; template