From patchwork Mon May 11 11:11:21 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 26709 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 BD989BDCBD for ; Mon, 11 May 2026 11:11:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CDF8C62E9D; Mon, 11 May 2026 13:11:24 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="sH/USSO1"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D68B062DC4 for ; Mon, 11 May 2026 13:11:22 +0200 (CEST) Received: from killaraus.ideasonboard.com (2001-14ba-70f3-e800--a06.rev.dnainternet.fi [IPv6:2001:14ba:70f3:e800::a06]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BD5EC244 for ; Mon, 11 May 2026 13:11:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1778497875; bh=c+E9c5UOz6YzV1cP1avah08NEMzFiGCt4YxsERzzy2I=; h=From:To:Subject:Date:From; b=sH/USSO1w8cJOoGr/21g9XgJEcrpLAAswKGruSRbODeWTdebo5wMh4+1vqAvBJ/34 /cwXHKnl0QxbIVzR44ZrTR10tQ+oeZ2mu5hfQocjqFFH8h864shVBI1p+ocI2AyJ8M 7FUVFXUmt6y7FAQsbDrH0siOdtGW/P8oljnh/9r4= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH v2] libcamera: bound_method: Use std::apply Date: Mon, 11 May 2026 14:11:21 +0300 Message-ID: <20260511111121.3042550-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.53.0 MIME-Version: 1.0 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" Now that libcamera uses C++17, we can use std::apply to replace the custom implementation. Signed-off-by: Laurent Pinchart Reviewed-by: Barnabás Pőcze --- Changes since v1: - Drop private invokePack() overload - Use lambda function and std::move() to avoid copy --- include/libcamera/base/bound_method.h | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) base-commit: 500c2320619a47bd01d1ffe69ca4cc6eae6e00e8 diff --git a/include/libcamera/base/bound_method.h b/include/libcamera/base/bound_method.h index 9b42a8a1e8ca..f11159e8a0a4 100644 --- a/include/libcamera/base/bound_method.h +++ b/include/libcamera/base/bound_method.h @@ -90,25 +90,19 @@ class BoundMethodArgs : public BoundMethodBase public: using PackType = BoundMethodPack; -private: - template - void invokePack(BoundMethodPackBase *pack, std::index_sequence) - { - [[maybe_unused]] auto *args = static_cast(pack); - - if constexpr (!std::is_void_v) - args->ret_ = invoke(std::forward(std::get(args->args_))...); - else - invoke(std::forward(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{}); + auto *argsPack = static_cast(pack); + + std::apply([&](Args &&...args) { + if constexpr (!std::is_void_v) + argsPack->ret_ = invoke(std::forward(args)...); + else + invoke(std::forward(args)...); + }, std::move(argsPack->args_)); } virtual R activate(Args... args, bool deleteMethod = false) = 0;