Patch Detail
Show a patch.
GET /api/1.1/patches/27006/?format=api
{ "id": 27006, "url": "https://patchwork.libcamera.org/api/1.1/patches/27006/?format=api", "web_url": "https://patchwork.libcamera.org/patch/27006/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20260621002305.3763752-3-laurent.pinchart@ideasonboard.com>", "date": "2026-06-21T00:23:03", "name": "[2/4] libcamera: vector: Swap order of arguments to apply()", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "3ef528492381a4083eea90668a4e9f4d39cc9fb9", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/27006/mbox/", "series": [ { "id": 6010, "url": "https://patchwork.libcamera.org/api/1.1/series/6010/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=6010", "date": "2026-06-21T00:23:01", "name": "libcamera: vector: Add clamp() function", "version": 1, "mbox": "https://patchwork.libcamera.org/series/6010/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/27006/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/27006/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 DEE01C3305\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 21 Jun 2026 00:23:14 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 25FF0656E9;\n\tSun, 21 Jun 2026 02:23:14 +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 DC3C9656E5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 21 Jun 2026 02:23:09 +0200 (CEST)", "from killaraus.ideasonboard.com\n\t(2001-14ba-70f3-e800--a06.rev.dnainternet.fi\n\t[IPv6:2001:14ba:70f3:e800::a06])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 05975268;\n\tSun, 21 Jun 2026 02:22:32 +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=\"TDXV6XVW\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1782001353;\n\tbh=MHe02q6CXE8PDIJbA2P3DGADl8LDSW7CvfPNOr4bwOY=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=TDXV6XVWm8lL7JQa6OJAun/P0zYGTednOxBGxaza6fVciQD36UM1Ka04S0N+xh8RY\n\tPG4y+qDBbjVwGenZMFMAhfKb2X9YHh7gjBTOuxbqTUCVIj1q3Ud+IgnkyU6uvUbQhq\n\thVNxYtfzRESErehJkeA2ZU4QSneu1dks5x3/nz3U=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Kieran Bingham <kieran.bingham@ideasonboard.com>", "Subject": "[PATCH 2/4] libcamera: vector: Swap order of arguments to apply()", "Date": "Sun, 21 Jun 2026 03:23:03 +0300", "Message-ID": "<20260621002305.3763752-3-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.53.0", "In-Reply-To": "<20260621002305.3763752-1-laurent.pinchart@ideasonboard.com>", "References": "<20260621002305.3763752-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "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": "The Vector class is lacking a clamp() function, which will take two\nscalar parameters. To support that, the apply() function will need to be\nconverted to variable number of parameters. This will require passing\nthe scalar parameter last, to make automatic template arguments\ndeduction possible.\n\nIn preparation for that change, swap the arguments to apply() to pass\nthe operation before the scalar parameter last. Only one variant of\napply() strictly requires this change, arguments to the three other\nfunctions are also swapped for consistency. Also for consistency, swap\nthe template arguments as well.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/internal/vector.h | 56 ++++++++++++++---------------\n 1 file changed, 28 insertions(+), 28 deletions(-)", "diff": "diff --git a/include/libcamera/internal/vector.h b/include/libcamera/internal/vector.h\nindex 04ba5d847b7d..256de1d1c53a 100644\n--- a/include/libcamera/internal/vector.h\n+++ b/include/libcamera/internal/vector.h\n@@ -73,116 +73,116 @@ public:\n \n \tconstexpr Vector operator+(const Vector &other) const\n \t{\n-\t\treturn apply(*this, other, std::plus<>{});\n+\t\treturn apply(*this, std::plus<>{}, other);\n \t}\n \n \tconstexpr Vector operator+(T scalar) const\n \t{\n-\t\treturn apply(*this, scalar, std::plus<>{});\n+\t\treturn apply(*this, std::plus<>{}, scalar);\n \t}\n \n \tconstexpr Vector operator-(const Vector &other) const\n \t{\n-\t\treturn apply(*this, other, std::minus<>{});\n+\t\treturn apply(*this, std::minus<>{}, other);\n \t}\n \n \tconstexpr Vector operator-(T scalar) const\n \t{\n-\t\treturn apply(*this, scalar, std::minus<>{});\n+\t\treturn apply(*this, std::minus<>{}, scalar);\n \t}\n \n \tconstexpr Vector operator*(const Vector &other) const\n \t{\n-\t\treturn apply(*this, other, std::multiplies<>{});\n+\t\treturn apply(*this, std::multiplies<>{}, other);\n \t}\n \n \tconstexpr Vector operator*(T scalar) const\n \t{\n-\t\treturn apply(*this, scalar, std::multiplies<>{});\n+\t\treturn apply(*this, std::multiplies<>{}, scalar);\n \t}\n \n \tconstexpr Vector operator/(const Vector &other) const\n \t{\n-\t\treturn apply(*this, other, std::divides<>{});\n+\t\treturn apply(*this, std::divides<>{}, other);\n \t}\n \n \tconstexpr Vector operator/(T scalar) const\n \t{\n-\t\treturn apply(*this, scalar, std::divides<>{});\n+\t\treturn apply(*this, std::divides<>{}, scalar);\n \t}\n \n \tconstexpr Vector operator>>(unsigned int shift) const\n \t{\n \t\tstatic_assert(std::is_integral_v<T>,\n \t\t\t \"Vector::operator>> requires an integer element type\");\n-\t\treturn apply(*this, shift, [](T a, unsigned int b) { return a >> b; });\n+\t\treturn apply(*this, [](T a, unsigned int b) { return a >> b; }, shift);\n \t}\n \n \tVector &operator+=(const Vector &other)\n \t{\n-\t\treturn apply(other, [](T a, T b) { return a + b; });\n+\t\treturn apply([](T a, T b) { return a + b; }, other);\n \t}\n \n \tVector &operator+=(T scalar)\n \t{\n-\t\treturn apply(scalar, [](T a, T b) { return a + b; });\n+\t\treturn apply([](T a, T b) { return a + b; }, scalar);\n \t}\n \n \tVector &operator-=(const Vector &other)\n \t{\n-\t\treturn apply(other, [](T a, T b) { return a - b; });\n+\t\treturn apply([](T a, T b) { return a - b; }, other);\n \t}\n \n \tVector &operator-=(T scalar)\n \t{\n-\t\treturn apply(scalar, [](T a, T b) { return a - b; });\n+\t\treturn apply([](T a, T b) { return a - b; }, scalar);\n \t}\n \n \tVector &operator*=(const Vector &other)\n \t{\n-\t\treturn apply(other, [](T a, T b) { return a * b; });\n+\t\treturn apply([](T a, T b) { return a * b; }, other);\n \t}\n \n \tVector &operator*=(T scalar)\n \t{\n-\t\treturn apply(scalar, [](T a, T b) { return a * b; });\n+\t\treturn apply([](T a, T b) { return a * b; }, scalar);\n \t}\n \n \tVector &operator/=(const Vector &other)\n \t{\n-\t\treturn apply(other, [](T a, T b) { return a / b; });\n+\t\treturn apply([](T a, T b) { return a / b; }, other);\n \t}\n \n \tVector &operator/=(T scalar)\n \t{\n-\t\treturn apply(scalar, [](T a, T b) { return a / b; });\n+\t\treturn apply([](T a, T b) { return a / b; }, scalar);\n \t}\n \n \tVector &operator>>=(unsigned int shift)\n \t{\n \t\tstatic_assert(std::is_integral_v<T>,\n \t\t\t \"Vector::operator>>= requires an integer element type\");\n-\t\treturn apply(shift, [](T a, unsigned int b) { return a >> b; });\n+\t\treturn apply([](T a, unsigned int b) { return a >> b; }, shift);\n \t}\n \n \tconstexpr Vector min(const Vector &other) const\n \t{\n-\t\treturn apply(*this, other, [](T a, T b) { return std::min(a, b); });\n+\t\treturn apply(*this, [](T a, T b) { return std::min(a, b); }, other);\n \t}\n \n \tconstexpr Vector min(T scalar) const\n \t{\n-\t\treturn apply(*this, scalar, [](T a, T b) { return std::min(a, b); });\n+\t\treturn apply(*this, [](T a, T b) { return std::min(a, b); }, scalar);\n \t}\n \n \tconstexpr Vector max(const Vector &other) const\n \t{\n-\t\treturn apply(*this, other, [](T a, T b) { return std::max(a, b); });\n+\t\treturn apply(*this, [](T a, T b) { return std::max(a, b); }, other);\n \t}\n \n \tconstexpr Vector max(T scalar) const\n \t{\n-\t\treturn apply(*this, scalar, [](T a, T b) -> T { return std::max(a, b); });\n+\t\treturn apply(*this, [](T a, T b) -> T { return std::max(a, b); }, scalar);\n \t}\n \n \tconstexpr T dot(const Vector<T, Rows> &other) const\n@@ -264,7 +264,7 @@ public:\n \n private:\n \ttemplate<typename BinaryOp>\n-\tstatic constexpr Vector apply(const Vector &lhs, const Vector &rhs, BinaryOp op)\n+\tstatic constexpr Vector apply(const Vector &lhs, BinaryOp op, const Vector &rhs)\n \t{\n \t\tVector result;\n \t\tstd::transform(lhs.data_.begin(), lhs.data_.end(),\n@@ -274,8 +274,8 @@ private:\n \t\treturn result;\n \t}\n \n-\ttemplate<typename U, typename BinaryOp>\n-\tstatic constexpr Vector apply(const Vector &lhs, U rhs, BinaryOp op)\n+\ttemplate<typename BinaryOp, typename U>\n+\tstatic constexpr Vector apply(const Vector &lhs, BinaryOp op, U rhs)\n \t{\n \t\tVector result;\n \t\tstd::transform(lhs.data_.begin(), lhs.data_.end(),\n@@ -286,7 +286,7 @@ private:\n \t}\n \n \ttemplate<typename BinaryOp>\n-\tVector &apply(const Vector &other, BinaryOp op)\n+\tVector &apply(BinaryOp op, const Vector &other)\n \t{\n \t\tauto itOther = other.data_.begin();\n \t\tstd::for_each(data_.begin(), data_.end(),\n@@ -295,8 +295,8 @@ private:\n \t\treturn *this;\n \t}\n \n-\ttemplate<typename U, typename BinaryOp>\n-\tVector &apply(U scalar, BinaryOp op)\n+\ttemplate<typename BinaryOp, typename U>\n+\tVector &apply(BinaryOp op, U scalar)\n \t{\n \t\tstd::for_each(data_.begin(), data_.end(),\n \t\t\t [&op, scalar](T &v) { v = op(v, scalar); });\n", "prefixes": [ "2/4" ] }