12 #ifndef RTCTK_COMPONENTFRAMEWORK_MATRIXSPAN_HPP
13 #define RTCTK_COMPONENTFRAMEWORK_MATRIXSPAN_HPP
29 using typename gsl::span<T>::element_type;
30 using typename gsl::span<T>::value_type;
31 using typename gsl::span<T>::size_type;
32 using typename gsl::span<T>::pointer;
34 using typename gsl::span<T>::reference;
36 using typename gsl::span<T>::iterator;
37 using typename gsl::span<T>::reverse_iterator;
39 constexpr
MatrixSpan() noexcept : gsl::span<T>(), m_nrows(0), m_ncols(0) {
43 : gsl::span<T>(other), m_nrows(other.m_nrows), m_ncols(other.m_ncols) {
47 gsl::span<T>::operator=(other);
48 m_nrows = other.m_nrows;
49 m_ncols = other.m_ncols;
54 : gsl::span<T>(std::forward<MatrixSpan>(other))
55 , m_nrows(std::move(other.m_nrows))
56 , m_ncols(std::move(other.m_ncols)) {
60 gsl::span<T>::operator=(std::forward<MatrixSpan>(other));
61 m_nrows = std::move(other.m_nrows);
62 m_ncols = std::move(other.m_ncols);
66 constexpr
explicit MatrixSpan(size_type n, size_type m,
const gsl::span<T>& data)
67 : gsl::span<T>(data), m_nrows(n), m_ncols(m) {
68 assert(n * m == data.size());
72 constexpr
explicit MatrixSpan(size_type n, size_type m, I first, size_type count)
73 : gsl::span<T>(first, count), m_nrows(n), m_ncols(m) {
74 assert(n * m == count);
78 constexpr
explicit MatrixSpan(size_type n, size_type m, I first, I last)
79 : gsl::span<T>(first, last), m_nrows(n), m_ncols(m) {
80 assert(n * m == std::distance(first, last));
83 template <std::
size_t N>
84 constexpr
explicit MatrixSpan(size_type n, size_type m, element_type (&array)[N]) noexcept
85 : gsl::span<T>(array), m_nrows(n), m_ncols(m) {
89 template <std::
size_t N>
90 constexpr
explicit MatrixSpan(size_type n, size_type m, std::array<T, N>& array) noexcept
91 : gsl::span<T>(array), m_nrows(n), m_ncols(m) {
95 template <std::
size_t N>
96 constexpr
explicit MatrixSpan(size_type n, size_type m,
const std::array<T, N>& array) noexcept
97 : gsl::span<T>(array), m_nrows(n), m_ncols(m) {
101 template <
typename R>
102 constexpr
explicit MatrixSpan(size_type n, size_type m, R&& range) noexcept
103 : gsl::span<T>(std::forward<R>(range)), m_nrows(n), m_ncols(m) {
104 assert(n * m == range.size());
107 template <
typename A>
109 : gsl::span<T>(buffer.data(), buffer.size())
110 , m_nrows(buffer.GetNrows())
111 , m_ncols(buffer.GetNcols()) {
115 assert(0 <= n and n < m_nrows);
116 assert(0 <= m and m < m_ncols);
117 return gsl::span<T>::operator[](n* m_ncols + m);
121 assert(0 <= n and n < m_nrows);
122 assert(0 <= m and m < m_ncols);
123 return gsl::span<T>::operator[](n* m_ncols + m);
141 #endif // RTCTK_COMPONENTFRAMEWORK_MATRIXSPAN_HPP