From patchwork Wed Mar 19 16:11:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 22982 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 2A39CC32FE for ; Wed, 19 Mar 2025 16:12:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D7A7D6895B; Wed, 19 Mar 2025 17:12:10 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="HQGEtgHn"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 987AF68950 for ; Wed, 19 Mar 2025 17:12:08 +0100 (CET) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:760:e5ca:4814:99c7]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A1FF38FA; Wed, 19 Mar 2025 17:10:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1742400625; bh=Wav+/7DNoCoKWjCuh5eKfA2krY3LS9nUcXcQ3tbPgbg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HQGEtgHncSgzwHAFvlib+/sZeOkooh1S3/wYl/Xg/iBdQepUC8RvLkaGRCYmEFfT5 S8hVSYRatAuUhXNHPiM8CEGP0pKgI/JGn1kKb6iQc0M5/cQ/MHKRqummJnZiF10+fl ugVU1TuMERPooxHNF31QvVkYwBcpKMzlSZyr+Xes= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v2 04/17] libcamera: vector: Add a Span based constructor Date: Wed, 19 Mar 2025 17:11:09 +0100 Message-ID: <20250319161152.63625-5-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250319161152.63625-1-stefan.klug@ideasonboard.com> References: <20250319161152.63625-1-stefan.klug@ideasonboard.com> MIME-Version: 1.0 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" Now that Matrix has a Span based constructor, add the same for Vector. Signed-off-by: Stefan Klug --- Changes in v2: - Added this patch --- include/libcamera/internal/vector.h | 12 ++++++++---- src/libcamera/vector.cpp | 8 ++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/include/libcamera/internal/vector.h b/include/libcamera/internal/vector.h index a67a09474204..66cc5ac988c2 100644 --- a/include/libcamera/internal/vector.h +++ b/include/libcamera/internal/vector.h @@ -40,10 +40,14 @@ public: data_.fill(scalar); } - constexpr Vector(const std::array &data) + Vector(const std::array &data) { - for (unsigned int i = 0; i < Rows; i++) - data_[i] = data[i]; + std::copy(data.begin(), data.end(), data_.begin()); + } + + Vector(const Span &data) + { + std::copy(data.begin(), data.end(), data_.begin()); } const T &operator[](size_t i) const @@ -285,7 +289,7 @@ private: return *this; } - std::array data_; + std::array data_{}; }; template diff --git a/src/libcamera/vector.cpp b/src/libcamera/vector.cpp index 85ca2208245a..435f2fc62f8b 100644 --- a/src/libcamera/vector.cpp +++ b/src/libcamera/vector.cpp @@ -44,6 +44,14 @@ LOG_DEFINE_CATEGORY(Vector) * The size of \a data must be equal to the dimension size Rows of the vector. */ +/** + * \fn Vector::Vector(const Span &data) + * \brief Construct vector from supplied data + * \param data Data from which to construct a vector + * + * The size of \a data must be equal to the dimension size Rows of the vector. + */ + /** * \fn T Vector::operator[](size_t i) const * \brief Index to an element in the vector