@@ -40,10 +40,14 @@ public:
data_.fill(scalar);
}
- constexpr Vector(const std::array<T, Rows> &data)
+ Vector(const std::array<T, Rows> &data)
{
- for (unsigned int i = 0; i < Rows; i++)
- data_[i] = data[i];
+ std::copy(data.begin(), data.end(), data_.begin());
+ }
+
+ Vector(const Span<const T, Rows> &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<T, Rows> data_;
+ std::array<T, Rows> data_{};
};
template<typename T>
@@ -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<const T, Rows> &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
Now that Matrix has a Span based constructor, add the same for Vector. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> --- Changes in v2: - Added this patch --- include/libcamera/internal/vector.h | 12 ++++++++---- src/libcamera/vector.cpp | 8 ++++++++ 2 files changed, 16 insertions(+), 4 deletions(-)