| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- #pragma once
- #include <cstdlib>
- #include <stdexcept>
- #include <expect/expect.hpp>
- #include <math/vector/vector.hpp>
- #include "math/matrix/macro.h"
- namespace math::matrix {
- template <typename T, size_t C> class row_reference {
- private:
- row_reference(T (&h)[C]) : _handle(h) {}
- public:
- row_reference(row_reference const &) = delete;
- row_reference(row_reference &&) = default;
- template <typename S>
- row_reference & operator=(row_reference<S, C> const & other) {
- VECTOR_FOR_EACH_RANGE(i, C) { _handle[i] = other[i]; }
- return *this;
- }
- T const & operator[](size_t col) const { return _handle[col]; }
- T & operator[](size_t col) { return _handle[col]; }
- T const & at(size_t col) const {
- expects(col < C, std::out_of_range, "column index out of range");
- return operator[](col);
- }
- T & at(size_t col) {
- expects(col < C, std::out_of_range, "column index out of range");
- return operator[](col);
- }
- private:
- template <typename _T, size_t R, size_t _C> friend class matrix;
- T (&_handle)[C];
- };
- }
- #include "math/matrix/undef.h"
|