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:
parent
aca9042abd
commit
bcba580546
2 changed files with 14 additions and 2 deletions
|
@ -42,8 +42,12 @@ public:
|
|||
|
||||
constexpr 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());
|
||||
}
|
||||
|
||||
constexpr Vector(const Span<const T, Rows> data)
|
||||
{
|
||||
std::copy(data.begin(), data.end(), data_.begin());
|
||||
}
|
||||
|
||||
const T &operator[](size_t i) const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue