[PATCH v4 04/17] ipa: libipa: vector: Add copy constructor and assignment operator
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Tue Nov 19 13:19:15 CET 2024
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 <laurent.pinchart at ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal at redhat.com>
---
Changes since v3:
- Default both functions
Changes since v2:
- Make copy constructor constexpr
- Drop #include <algorithm>
---
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());
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list