@@ -63,6 +63,17 @@ public:
return data_[i];
}
+ template<typename T2>
+ explicit operator Vector<T2, Rows>() const
+ {
+ Vector<T2, Rows> ret;
+ for (unsigned int i = 0; i < Rows; i++)
+ ret[i] = static_cast<T2>(data_[i]);
+ return ret;
+ }
+
+ constexpr Span<const T, Rows> data() const { return data_; }
+
constexpr Vector<T, Rows> operator-() const
{
Vector<T, Rows> ret;
@@ -64,6 +64,24 @@ LOG_DEFINE_CATEGORY(Vector)
* \copydoc Vector::operator[](size_t i) const
*/
+/**
+ * \fn Vector::data()
+ * \brief Access the vector data
+ *
+ * Access the contents of the vector as linear array of values.
+ *
+ * \return A span referencing the vector data as a linear array
+ */
+
+/**
+ * \fn Vector::operator Vector<T2, Rows>()
+ * \brief Cast to a different underlying type
+ *
+ * Cast the vector to a different underlying type using static_cast().
+ *
+ * \return A vector of type T2
+ */
+
/**
* \fn Vector::operator-() const
* \brief Negate a Vector by negating both all of its coordinates
When dealing with Vectors it is useful to be able to cast the to a different underlying type or to access the underlying data. Add functions for that. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> --- include/libcamera/internal/vector.h | 11 +++++++++++ src/libcamera/vector.cpp | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+)