Patch Detail
Show a patch.
GET /api/patches/23598/?format=api
{ "id": 23598, "url": "https://patchwork.libcamera.org/api/patches/23598/?format=api", "web_url": "https://patchwork.libcamera.org/patch/23598/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20250618144536.443175-1-barnabas.pocze@ideasonboard.com>", "date": "2025-06-18T14:45:36", "name": "[v1] libcamera: base: bound_method: Move return value", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "6c22c1008c55beebe89aa687f56aac6af96eb942", "submitter": { "id": 216, "url": "https://patchwork.libcamera.org/api/people/216/?format=api", "name": "Barnabás Pőcze", "email": "barnabas.pocze@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/23598/mbox/", "series": [ { "id": 5229, "url": "https://patchwork.libcamera.org/api/series/5229/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5229", "date": "2025-06-18T14:45:36", "name": "[v1] libcamera: base: bound_method: Move return value", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5229/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/23598/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/23598/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id D7F11BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 18 Jun 2025 14:45:42 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EC64568DCC;\n\tWed, 18 Jun 2025 16:45:41 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 447DE68DC1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 18 Jun 2025 16:45:40 +0200 (CEST)", "from pb-laptop.local (185.221.143.107.nat.pool.zt.hu\n\t[185.221.143.107])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 055ED752\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 18 Jun 2025 16:45:26 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"k2UVpDvz\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1750257927;\n\tbh=9eo1zmBLv2fTOWIQrpgu78zcyo/qb9xmSSEnpRyEUuM=;\n\th=From:To:Subject:Date:From;\n\tb=k2UVpDvzsrnk9PIXgtagYXS9D4GWDwwIA/Ryiee0eIidqGi7Nqz4u+j8w4ieeE7f/\n\tMAVpIxGmQmaY37XviBNnfu8+k+GXXNWWhQWvNhAYj9lK7xdRwIQ9cbmXp+3Z44vcoL\n\t6M2h4WN/1/5cS+Ad7UYPRRTwbn3pFQFnucPbSvog=", "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[PATCH v1] libcamera: base: bound_method: Move return value", "Date": "Wed, 18 Jun 2025 16:45:36 +0200", "Message-ID": "<20250618144536.443175-1-barnabas.pocze@ideasonboard.com>", "X-Mailer": "git-send-email 2.50.0", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Instead of copying, just move the returned value when the call is made\nthrough an argument pack. This enables, e.g. `Object::invokeMethod()`\nto be usable with functions returning types, such as`std::unique_ptr`,\nthat have no copy ctor/assignment. Since there are no other users of\nthe argument pack object, this is safe to do. Reference return types\nare not supported, so a simple `std::move()` is sufficient.\n\nLink: https://bugs.libcamera.org/show_bug.cgi?id=273#c1\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\n include/libcamera/base/bound_method.h | 17 ++++++-----------\n test/object-invoke.cpp | 16 ++++++++++++++++\n 2 files changed, 22 insertions(+), 11 deletions(-)", "diff": "diff --git a/include/libcamera/base/bound_method.h b/include/libcamera/base/bound_method.h\nindex 507c320d3..8b433a0da 100644\n--- a/include/libcamera/base/bound_method.h\n+++ b/include/libcamera/base/bound_method.h\n@@ -38,11 +38,6 @@ public:\n \t{\n \t}\n \n-\tR returnValue()\n-\t{\n-\t\treturn ret_;\n-\t}\n-\n \tstd::tuple<typename std::remove_reference_t<Args>...> args_;\n \tR ret_;\n };\n@@ -56,10 +51,6 @@ public:\n \t{\n \t}\n \n-\tvoid returnValue()\n-\t{\n-\t}\n-\n \tstd::tuple<typename std::remove_reference_t<Args>...> args_;\n };\n \n@@ -141,7 +132,9 @@ public:\n \n \t\tauto pack = std::make_shared<PackType>(args...);\n \t\tbool sync = BoundMethodBase::activatePack(pack, deleteMethod);\n-\t\treturn sync ? pack->returnValue() : R();\n+\n+\t\tif constexpr (!std::is_void_v<R>)\n+\t\t\treturn sync ? std::move(pack->ret_) : R();\n \t}\n \n \tR invoke(Args... args) override\n@@ -176,7 +169,9 @@ public:\n \n \t\tauto pack = std::make_shared<PackType>(args...);\n \t\tbool sync = BoundMethodBase::activatePack(pack, deleteMethod);\n-\t\treturn sync ? pack->returnValue() : R();\n+\n+\t\tif constexpr (!std::is_void_v<R>)\n+\t\t\treturn sync ? std::move(pack->ret_) : R();\n \t}\n \n \tR invoke(Args... args) override\ndiff --git a/test/object-invoke.cpp b/test/object-invoke.cpp\nindex def1e61e4..d309cff15 100644\n--- a/test/object-invoke.cpp\n+++ b/test/object-invoke.cpp\n@@ -58,6 +58,19 @@ public:\n \t\treturn 42;\n \t}\n \n+\tstruct MoveOnly {\n+\t\tMoveOnly() = default;\n+\t\tMoveOnly(const MoveOnly &) = delete;\n+\t\tMoveOnly &operator=(const MoveOnly &) = delete;\n+\t\tMoveOnly(MoveOnly &&) = default;\n+\t\tMoveOnly &operator=(MoveOnly &&) = default;\n+\t};\n+\n+\tMoveOnly methodWithReturnMoveOnly()\n+\t{\n+\t\treturn {};\n+\t}\n+\n private:\n \tStatus status_;\n \tint value_;\n@@ -186,6 +199,9 @@ protected:\n \t\t\treturn TestFail;\n \t\t}\n \n+\t\t/* Test invoking a method that returns type with no copy ctor/assignment. */\n+\t\tobject_.invokeMethod(&InvokedObject::methodWithReturnMoveOnly, ConnectionTypeBlocking);\n+\n \t\treturn TestPass;\n \t}\n \n", "prefixes": [ "v1" ] }