[{"id":39207,"web_url":"https://patchwork.libcamera.org/comment/39207/","msgid":"<178204435937.1686300.12211740945651668294@ping.linuxembedded.co.uk>","date":"2026-06-21T12:19:19","subject":"Re: [PATCH 3/4] libcamera: vector: Support multiple scalar arguments\n\tto apply()","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart (2026-06-21 01:23:04)\n> In preparation for the addition of a clamp() function to the vector\n> class, extend the apply() function to support multiple scalar arguments.\n\nso I tried to look at using apply, fell down the rabbit hole of seeing\nI'd need to add a second instance and gave up (and posted what I had).\n\nSo ... ok this could be cleaner indeed. If it gets through CI it's fine\nwith me.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  include/libcamera/internal/vector.h | 14 +++++++-------\n>  1 file changed, 7 insertions(+), 7 deletions(-)\n> \n> diff --git a/include/libcamera/internal/vector.h b/include/libcamera/internal/vector.h\n> index 256de1d1c53a..7c90d6542352 100644\n> --- a/include/libcamera/internal/vector.h\n> +++ b/include/libcamera/internal/vector.h\n> @@ -274,13 +274,13 @@ private:\n>                 return result;\n>         }\n>  \n> -       template<typename BinaryOp, typename U>\n> -       static constexpr Vector apply(const Vector &lhs, BinaryOp op, U rhs)\n> +       template<typename Op, typename... U>\n> +       static constexpr Vector apply(const Vector &vector, Op op, U... scalar)\n>         {\n>                 Vector result;\n> -               std::transform(lhs.data_.begin(), lhs.data_.end(),\n> +               std::transform(vector.data_.begin(), vector.data_.end(),\n>                                result.data_.begin(),\n> -                              [&op, rhs](T v) { return op(v, rhs); });\n> +                              [&op, scalar...](T v) { return op(v, scalar...); });\n>  \n>                 return result;\n>         }\n> @@ -295,11 +295,11 @@ private:\n>                 return *this;\n>         }\n>  \n> -       template<typename BinaryOp, typename U>\n> -       Vector &apply(BinaryOp op, U scalar)\n> +       template<typename Op, typename... U>\n> +       Vector &apply(Op op, U... scalar)\n>         {\n>                 std::for_each(data_.begin(), data_.end(),\n> -                             [&op, scalar](T &v) { v = op(v, scalar); });\n> +                             [&op, scalar...](T &v) { v = op(v, scalar...); });\n>  \n>                 return *this;\n>         }\n> -- \n> Regards,\n> \n> Laurent Pinchart\n>","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 4E459C3261\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 21 Jun 2026 12:19:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F15A365702;\n\tSun, 21 Jun 2026 14:19:22 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8AA0F61F3F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 21 Jun 2026 14:19:21 +0200 (CEST)","from monstersaurus.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6563B236;\n\tSun, 21 Jun 2026 14:18:44 +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=\"JvcfyJI9\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1782044324;\n\tbh=VzngNYl2WqscaBHyJ9reoh96sP3IhKfi9MbXPgcCK8s=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=JvcfyJI9lbJNrFcKNTCvPnsitwvD60rX9+9RK4v2G/skQRvH5//WO2WdIn5gqvkrC\n\tLx/Qq4X2pEcpi6F7zMzjUTbEGwgkQkaVsJ5PpPvJ+7ZSCAGRSb+G2OWtQld3AEVeVa\n\tlAEz0f9WyWbi4+pCV4k2JZ2LzHVcihKoE9bbFSjc=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20260621002305.3763752-4-laurent.pinchart@ideasonboard.com>","References":"<20260621002305.3763752-1-laurent.pinchart@ideasonboard.com>\n\t<20260621002305.3763752-4-laurent.pinchart@ideasonboard.com>","Subject":"Re: [PATCH 3/4] libcamera: vector: Support multiple scalar arguments\n\tto apply()","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Sun, 21 Jun 2026 13:19:19 +0100","Message-ID":"<178204435937.1686300.12211740945651668294@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","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>"}},{"id":39214,"web_url":"https://patchwork.libcamera.org/comment/39214/","msgid":"<3752fb93-d5a4-43e5-841b-55baf20cff85@ideasonboard.com>","date":"2026-06-22T07:54:04","subject":"Re: [PATCH 3/4] libcamera: vector: Support multiple scalar arguments\n\tto apply()","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"2026. 06. 21. 2:23 keltezéssel, Laurent Pinchart írta:\n> In preparation for the addition of a clamp() function to the vector\n> class, extend the apply() function to support multiple scalar arguments.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n\nReviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n\n\n>   include/libcamera/internal/vector.h | 14 +++++++-------\n>   1 file changed, 7 insertions(+), 7 deletions(-)\n> \n> diff --git a/include/libcamera/internal/vector.h b/include/libcamera/internal/vector.h\n> index 256de1d1c53a..7c90d6542352 100644\n> --- a/include/libcamera/internal/vector.h\n> +++ b/include/libcamera/internal/vector.h\n> @@ -274,13 +274,13 @@ private:\n>   \t\treturn result;\n>   \t}\n>   \n> -\ttemplate<typename BinaryOp, typename U>\n> -\tstatic constexpr Vector apply(const Vector &lhs, BinaryOp op, U rhs)\n> +\ttemplate<typename Op, typename... U>\n> +\tstatic constexpr Vector apply(const Vector &vector, Op op, U... scalar)\n>   \t{\n>   \t\tVector result;\n> -\t\tstd::transform(lhs.data_.begin(), lhs.data_.end(),\n> +\t\tstd::transform(vector.data_.begin(), vector.data_.end(),\n>   \t\t\t       result.data_.begin(),\n> -\t\t\t       [&op, rhs](T v) { return op(v, rhs); });\n> +\t\t\t       [&op, scalar...](T v) { return op(v, scalar...); });\n>   \n>   \t\treturn result;\n>   \t}\n> @@ -295,11 +295,11 @@ private:\n>   \t\treturn *this;\n>   \t}\n>   \n> -\ttemplate<typename BinaryOp, typename U>\n> -\tVector &apply(BinaryOp op, U scalar)\n> +\ttemplate<typename Op, typename... U>\n> +\tVector &apply(Op 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> +\t\t\t      [&op, scalar...](T &v) { v = op(v, scalar...); });\n>   \n>   \t\treturn *this;\n>   \t}","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 2D9D5C3303\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 22 Jun 2026 07:54:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D3B4C65708;\n\tMon, 22 Jun 2026 09:54:06 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 088E56570B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 22 Jun 2026 09:54:05 +0200 (CEST)","from [192.168.33.39] (185.221.141.133.nat.pool.zt.hu\n\t[185.221.141.133])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1BE0C1E6;\n\tMon, 22 Jun 2026 09:53: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=\"iCwI9hPG\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1782114807;\n\tbh=CqjsFHM/uc6J3A3Qh7pb+bacY3KNYxreIEYjJmD0tVk=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=iCwI9hPGXLbafoFDCKA0E77OyokM0R2q+e3y1Jj0fk/SVHUt2bj+SHiGh9tTj8pAB\n\tDQdi4mWNx0v1hDMLWnrmZds0HGgW8KRpaDO9s6KWLOabV8Yxy/Lc9Pxq4zbk/x2vXB\n\tbTRBGoUkJ/gUHgb3QlWknr/tchNM9ry3Tt0D98fo=","Message-ID":"<3752fb93-d5a4-43e5-841b-55baf20cff85@ideasonboard.com>","Date":"Mon, 22 Jun 2026 09:54:04 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH 3/4] libcamera: vector: Support multiple scalar arguments\n\tto apply()","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Cc":"Kieran Bingham <kieran.bingham@ideasonboard.com>","References":"<20260621002305.3763752-1-laurent.pinchart@ideasonboard.com>\n\t<20260621002305.3763752-4-laurent.pinchart@ideasonboard.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20260621002305.3763752-4-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","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>"}}]