Support indexing zero-dimensional matrices

This commit is contained in:
Nikita Lisitsa 2021-01-16 22:42:55 +03:00
parent 6d22ae95c7
commit 7698e54b18
2 changed files with 4 additions and 2 deletions

View file

@ -27,6 +27,8 @@ namespace psemek::geom::detail
{ {
T const & operator[](std::size_t) const { throw empty_array_exception{}; } T const & operator[](std::size_t) const { throw empty_array_exception{}; }
T & operator[](std::size_t) { throw empty_array_exception{}; } T & operator[](std::size_t) { throw empty_array_exception{}; }
type operator + (std::size_t) const { return *this; }
}; };
}; };

View file

@ -18,12 +18,12 @@ namespace psemek::geom
detail::array<T, R * C>::type coords; detail::array<T, R * C>::type coords;
T * operator[](std::size_t i) auto operator[](std::size_t i)
{ {
return coords + C * i; return coords + C * i;
} }
T const * operator[](std::size_t i) const auto operator[](std::size_t i) const
{ {
return coords + C * i; return coords + C * i;
} }