From patchwork Mon Nov 18 22:16:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 21964 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 4F858C32EA for ; Mon, 18 Nov 2024 22:16:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BD9F1658FB; Mon, 18 Nov 2024 23:16:41 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="wZVblFTt"; 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 B7E1B658F9 for ; Mon, 18 Nov 2024 23:16:33 +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 B48778DB for ; Mon, 18 Nov 2024 23:16:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1731968176; bh=8rcuaTIQJIPsp30V5RFodG0Vgjh3hhCgRHL2U2sQoro=; h=From:To:Subject:Date:In-Reply-To:References:From; b=wZVblFTtAXixJ5xQJwHbhIE+pAnV+RuSETtCD4/mdzBOGwKLggZAhzj/iE6453gAa VaFDKafpVmqIKvO8oMxjthEFuE6pcAHj5HQnm/ADnbOrAqQJR2Tv6BD2X9fi2sWvGy Sg+ag5Qoe/VQ/qslhiX3G0z+Kvyh2Dct6l3zbVfI= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH v3 04/17] ipa: libipa: vector: Add copy constructor and assignment operator Date: Tue, 19 Nov 2024 00:16:05 +0200 Message-ID: <20241118221618.13953-5-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241118221618.13953-1-laurent.pinchart@ideasonboard.com> References: <20241118221618.13953-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 --- Changes since v2: - Make copy constructor constexpr - Drop #include --- src/ipa/libipa/vector.cpp | 13 +++++++++++++ src/ipa/libipa/vector.h | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/ipa/libipa/vector.cpp b/src/ipa/libipa/vector.cpp index d414ba97e41e..80f1758578f0 100644 --- a/src/ipa/libipa/vector.cpp +++ b/src/ipa/libipa/vector.cpp @@ -46,6 +46,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 be568eadfeac..35fc9539dc99 100644 --- a/src/ipa/libipa/vector.h +++ b/src/ipa/libipa/vector.h @@ -46,6 +46,18 @@ public: data_[i] = data[i]; } + constexpr 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());