libcamera: vector: Add a Span based constructor

When one wants to create a Vector from existing data, currently the only
way is via std::array. Add a Span based constructor to allow creation
from std::vectors and alike.

While at it, replace the manual loop with std::copy.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
This commit is contained in:
Stefan Klug 2025-04-03 17:49:09 +02:00
parent aca9042abd
commit bcba580546
2 changed files with 14 additions and 2 deletions

View file

@ -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