Patch Detail
Show a patch.
GET /api/patches/23185/?format=api
{ "id": 23185, "url": "https://patchwork.libcamera.org/api/patches/23185/?format=api", "web_url": "https://patchwork.libcamera.org/patch/23185/", "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": "<20250417113539.1137936-2-barnabas.pocze@ideasonboard.com>", "date": "2025-04-17T11:35:38", "name": "[v1,2/3] libcamera: controls: Implement move ctor/assignment", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "948d6a521aaf2aebf70fa0e1496b6266548a9c7d", "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/23185/mbox/", "series": [ { "id": 5131, "url": "https://patchwork.libcamera.org/api/series/5131/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5131", "date": "2025-04-17T11:35:37", "name": "[v1,1/3] libcamera: controls: Give name to the union containing storage", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5131/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/23185/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/23185/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 A8C62C3213\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 17 Apr 2025 11:35:49 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9948A68ACA;\n\tThu, 17 Apr 2025 13:35:46 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A94EF68AB8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 17 Apr 2025 13:35:43 +0200 (CEST)", "from pb-laptop.local (185.221.143.16.nat.pool.zt.hu\n\t[185.221.143.16])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 071037E0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 17 Apr 2025 13:33:39 +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=\"WdJ04FJ5\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1744889620;\n\tbh=fAkcG0jCLSKsiKuClGSPd6cxE1FWezwBJPnmbcYn0To=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=WdJ04FJ52pzVt7nuRsc9y+i+5guLQwbfJeYh9UkTEhUIXjSJI0Dxbtx8yUEyH2vaf\n\tnZrXHiiH4HnX7V7eJBJeweJ2SeCksFfSWScFwHGZf8qP+AO67u7jvYYAi1Q1BHD9JE\n\tNmKTFhB1Ud0HXlXk5lIgQTpSPup6fGMucftotOs4=", "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[PATCH v1 2/3] libcamera: controls: Implement move ctor/assignment", "Date": "Thu, 17 Apr 2025 13:35:38 +0200", "Message-ID": "<20250417113539.1137936-2-barnabas.pocze@ideasonboard.com>", "X-Mailer": "git-send-email 2.49.0", "In-Reply-To": "<20250417113539.1137936-1-barnabas.pocze@ideasonboard.com>", "References": "<20250417113539.1137936-1-barnabas.pocze@ideasonboard.com>", "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": "Implement a move constructor and move assignment operator for `ControlValue`.\nThe `ControlValue` type already has an \"empty\" state that it used when\ncreating a default constructed `ControlValue`, so have the moved-from\ninstance return to that state after move construction/assignment.\n\nThis is useful, for example, for `std::vector` as most implementations will\nuse the copy constructor when reallocating if no nothrow move constructor\nis available. Having a nothrow move constructor avoids the extra copies.\nIt is also useful when using temporaries of `ControlValue` with other\ncontainers such as `std::optional`, and it also makes `ControlInfo`\n\"cheaply\" move constructible/assignable.\n\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\n include/libcamera/controls.h | 28 ++++++++++++++++++++++++++++\n src/libcamera/controls.cpp | 17 +++++++++++++++++\n 2 files changed, 45 insertions(+)", "diff": "diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\nindex 1dc6ccffa..86245e7a9 100644\n--- a/include/libcamera/controls.h\n+++ b/include/libcamera/controls.h\n@@ -14,6 +14,7 @@\n #include <stdint.h>\n #include <string>\n #include <unordered_map>\n+#include <utility>\n #include <vector>\n \n #include <libcamera/base/class.h>\n@@ -165,6 +166,33 @@ public:\n \tControlValue(const ControlValue &other);\n \tControlValue &operator=(const ControlValue &other);\n \n+\tControlValue(ControlValue &&other) noexcept\n+\t\t: type_(other.type_),\n+\t\t isArray_(std::exchange(other.isArray_, false)),\n+\t\t numElements_(other.numElements_),\n+\t\t storage_(std::exchange(other.storage_, {}))\n+\t{\n+\t\tother.type_ = ControlTypeNone;\n+\t\tother.numElements_ = 0;\n+\t}\n+\n+\tControlValue &operator=(ControlValue &&other) noexcept\n+\t{\n+\t\tif (this != &other) {\n+\t\t\trelease();\n+\n+\t\t\ttype_ = other.type_;\n+\t\t\tisArray_ = std::exchange(other.isArray_, false);\n+\t\t\tnumElements_ = other.numElements_;\n+\t\t\tstorage_ = std::exchange(other.storage_, {});\n+\n+\t\t\tother.type_ = ControlTypeNone;\n+\t\t\tother.numElements_ = 0;\n+\t\t}\n+\n+\t\treturn *this;\n+\t}\n+\n \tControlType type() const { return type_; }\n \tbool isNone() const { return type_ == ControlTypeNone; }\n \tbool isArray() const { return isArray_; }\ndiff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nindex d384e1ef7..885287e71 100644\n--- a/src/libcamera/controls.cpp\n+++ b/src/libcamera/controls.cpp\n@@ -155,6 +155,23 @@ ControlValue &ControlValue::operator=(const ControlValue &other)\n \treturn *this;\n }\n \n+/**\n+ * \\fn ControlValue::ControlValue(ControlValue &&other) noexcept\n+ * \\brief Move constructor for ControlValue\n+ * \\param[in] other The ControlValue object to move from\n+ *\n+ * Move constructs a ControlValue instance from \\a other. After this opreation\n+ * \\a other will be in the same state as a default constructed ControlValue instance.\n+ */\n+\n+/**\n+ * \\fn ControlValue &ControlValue::operator=(ControlValue &&other) noexcept\n+ * \\brief Move assignment operator for ControlValue\n+ * \\param[in] other The ControlValue object to move from\n+ *\n+ * \\sa ControlValue::ControlValue(ControlValue &&other)\n+ */\n+\n /**\n * \\fn ControlValue::type()\n * \\brief Retrieve the data type of the value\n", "prefixes": [ "v1", "2/3" ] }