From patchwork Tue Nov 19 12:19:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 22002 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 51C7EC32F3 for ; Tue, 19 Nov 2024 12:19:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E013065F1E; Tue, 19 Nov 2024 13:19:55 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="FS5SazD5"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9733B65F17 for ; Tue, 19 Nov 2024 13:19:52 +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 10E34D49 for ; Tue, 19 Nov 2024 13:19:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1732018775; bh=5Zv5KgDrmGIcqXYK6hyPDOV8YehMaKAZxQowAfWz/9c=; h=From:To:Subject:Date:In-Reply-To:References:From; b=FS5SazD51sXlLkttyV+dSxJQ0Yp/5GKKdrhzp9Qf35gldqkYslcXpS11l+ePcC2Gh ngGUU6wXPg4QzUdr851qhqtra+32e1CXpJj4iOhysb5BLMQxwghdzb71LsLAAeA75v WrE8Alz4yubFMnBS088c8yhkw249cHtM/P6RLP2c= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH v4 04/17] ipa: libipa: vector: Add copy constructor and assignment operator Date: Tue, 19 Nov 2024 14:19:15 +0200 Message-ID: <20241119121928.30939-5-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241119121928.30939-1-laurent.pinchart@ideasonboard.com> References: <20241119121928.30939-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 v3: - Default both functions Changes since v2: - Make copy constructor constexpr - Drop #include --- src/ipa/libipa/vector.cpp | 13 +++++++++++++ src/ipa/libipa/vector.h | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/src/ipa/libipa/vector.cpp b/src/ipa/libipa/vector.cpp index 5851b9ae2ed3..a9779fa2b8e2 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 5fb7ad7c95dd..1022550e6170 100644 --- a/src/ipa/libipa/vector.h +++ b/src/ipa/libipa/vector.h @@ -46,6 +46,10 @@ public: data_[i] = data[i]; } + constexpr Vector(const Vector &other) = default; + + Vector &operator=(const Vector &other) = default; + const T &operator[](size_t i) const { ASSERT(i < data_.size());