matrix: assert that index values are valid
This commit is contained in:
parent
44f8496256
commit
563ffaf894
16
matrix.hpp
16
matrix.hpp
@ -74,10 +74,22 @@ namespace util {
|
|||||||
// index operators return a pointer into the data array so that
|
// index operators return a pointer into the data array so that
|
||||||
// multidimensional array syntax can be used transparently on this
|
// multidimensional array syntax can be used transparently on this
|
||||||
// type.
|
// type.
|
||||||
constexpr row_t& operator[] (std::size_t idx)& { return values[idx]; }
|
constexpr row_t&
|
||||||
constexpr const row_t& operator[] (std::size_t idx) const& { return values[idx]; }
|
operator[] (std::size_t idx)&
|
||||||
|
{
|
||||||
|
CHECK_LT (idx, rows);
|
||||||
|
return values[idx];
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
constexpr const row_t&
|
||||||
|
operator[] (std::size_t idx) const&
|
||||||
|
{
|
||||||
|
CHECK_LT (idx, rows);
|
||||||
|
return values[idx];
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////
|
||||||
constexpr row_t*
|
constexpr row_t*
|
||||||
data (void)& noexcept
|
data (void)& noexcept
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user