From patchwork Tue Apr 7 22:01:12 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 26492 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 13676C32F7 for ; Tue, 7 Apr 2026 22:03:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A6E2362DA7; Wed, 8 Apr 2026 00:02:53 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="OWT8u0yi"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E59A062DA8 for ; Wed, 8 Apr 2026 00:02:42 +0200 (CEST) Received: from [192.168.0.204] (ams.linuxembedded.co.uk [209.38.108.23]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 427F578E; Wed, 8 Apr 2026 00:01:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1775599275; bh=oozcjV0cZYSOeVz0QApO4JVpN6M3yAnj1517g54bPlQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=OWT8u0yidvsv9CZnvowc2BvN+UGcrbsMSh+wmexQcSBiTId1XxNj+iUQwDItF/jRp vT4xh6ZrjakK6++YWPLxV3CU2t61KZtBEdblfnTmiW1NqoOnLWyJbeki86kHyAzW91 weBzTb0ixOdd03FIsaVXem5ny9KeFrWjdHo0glII= From: Kieran Bingham Date: Tue, 07 Apr 2026 23:01:12 +0100 Subject: [PATCH 09/13] libcamera: vector: Convertor Constructor MIME-Version: 1.0 Message-Id: <20260407-kbingham-awb-split-v1-9-a39af3f4dc20@ideasonboard.com> References: <20260407-kbingham-awb-split-v1-0-a39af3f4dc20@ideasonboard.com> In-Reply-To: <20260407-kbingham-awb-split-v1-0-a39af3f4dc20@ideasonboard.com> To: libcamera-devel@lists.libcamera.org Cc: Kieran Bingham X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1775599360; l=1757; i=kieran.bingham@ideasonboard.com; s=20260204; h=from:subject:message-id; bh=oozcjV0cZYSOeVz0QApO4JVpN6M3yAnj1517g54bPlQ=; b=VRRG1WjbZKei9rJaWng/94lcPy49YA2lH8SifodcvKa5VlV/nENRTUdyD2U37BIZ5Gvdh0mHb Yowe1me0IMJBSX2Xh3vrafzquzdjIUEqoofb3xxB7jtQHlge4NgVg+z X-Developer-Key: i=kieran.bingham@ideasonboard.com; a=ed25519; pk=IOxS2C6nWHNjLfkDR71Iesk904i6wJDfEERqV7hDBdY= 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" Extend the Vector class with a constructor to support casting to the storage type when the given parameters are compatible. Signed-off-by: Kieran Bingham --- include/libcamera/internal/vector.h | 8 ++++++++ src/libcamera/vector.cpp | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/include/libcamera/internal/vector.h b/include/libcamera/internal/vector.h index 16b6aef0b38f4b094d83449b5cdb1ba48b17c2bf..d29547f170e37c15f85e46abca82f89c8995115d 100644 --- a/include/libcamera/internal/vector.h +++ b/include/libcamera/internal/vector.h @@ -51,6 +51,14 @@ public: std::copy(data.begin(), data.end(), data_.begin()); } + template && + !std::is_same_v> * = nullptr> + constexpr Vector(const Vector &other) + { + for (unsigned int i = 0; i < Rows; i++) + data_[i] = static_cast(other[i]); + } + const T &operator[](size_t i) const { ASSERT(i < data_.size()); diff --git a/src/libcamera/vector.cpp b/src/libcamera/vector.cpp index 4dad1b9001c5df97f71031724729563cae0962c3..397e370fd023caef069095dc5abebe2d6d76848a 100644 --- a/src/libcamera/vector.cpp +++ b/src/libcamera/vector.cpp @@ -52,6 +52,13 @@ LOG_DEFINE_CATEGORY(Vector) * The size of \a data must be equal to the dimension size Rows of the vector. */ +/** + * \fn Vector::Vector(const Vector &other) + * \brief Construct a vector by converting another vector's element type + * \tparam U The source vector element type + * \param[in] other The vector to convert from + */ + /** * \fn T Vector::operator[](size_t i) const * \brief Index to an element in the vector