From patchwork Mon Nov 18 00:07:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 21945 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 3E2F1C32EF for ; Mon, 18 Nov 2024 00:07:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9664E658B5; Mon, 18 Nov 2024 01:07:56 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="M4nLx1Ky"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BD32F658B3 for ; Mon, 18 Nov 2024 01:07:51 +0100 (CET) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5BB2175A for ; Mon, 18 Nov 2024 01:07:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1731888455; bh=u9dR8L8pQLloFRR66pjmoAU0G54ZdDGmseZUGeLoWa4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=M4nLx1Ky7QiL8RF7IrPx5/46Tzg+lRIIt3q0aj3FQOXhA/Bz2Iao5/1o3zEBOJU2K UkVBvp5YJcV/8Ek/T4wl1LDpKTtJi21/iq4sPL9PA9Z3r2x2d9AtRbb3C+AoF4fH9z txIepTwUxzgPeHNwRR6ldQhQr5UzTeZ+OJmMOdTw= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [RFC PATCH v2 03/12] ipa: libipa: vector: Add copy constructor and assignment operator Date: Mon, 18 Nov 2024 02:07:29 +0200 Message-ID: <20241118000738.18977-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241118000738.18977-1-laurent.pinchart@ideasonboard.com> References: <20241118000738.18977-1-laurent.pinchart@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" It is useful to assign a value to an existing vector. Define a copy constructor and a copy assignment operator. Signed-off-by: Laurent Pinchart Reviewed-by: Milan Zamazal --- src/ipa/libipa/vector.cpp | 13 +++++++++++++ src/ipa/libipa/vector.h | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/ipa/libipa/vector.cpp b/src/ipa/libipa/vector.cpp index f14f155216f3..df089f8aed9f 100644 --- a/src/ipa/libipa/vector.cpp +++ b/src/ipa/libipa/vector.cpp @@ -40,6 +40,19 @@ namespace ipa { * 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 copying \a other + * \param[in] other The other Vector value + */ + +/** + * \fn Vector &Vector::operator=(const Vector &other) + * \brief Replace the content of the Vector with a copy of the content of \a other + * \param[in] other The other Vector value + * \return This Vector value + */ + /** * \fn T Vector::operator[](size_t i) const * \brief Index to an element in the vector diff --git a/src/ipa/libipa/vector.h b/src/ipa/libipa/vector.h index b72ab9851aa3..50e16250acfd 100644 --- a/src/ipa/libipa/vector.h +++ b/src/ipa/libipa/vector.h @@ -6,6 +6,7 @@ */ #pragma once +#include #include #include #include @@ -41,6 +42,18 @@ public: data_[i] = data[i]; } + Vector(const Vector &other) + : data_(other.data_) + { + } + + Vector &operator=(const Vector &other) + { + data_ = other.data_; + + return *this; + } + const T &operator[](size_t i) const { ASSERT(i < data_.size());