matrix: assert that index values are valid

This commit is contained in:
Danny Robson 2018-03-13 22:35:05 +11:00
parent 44f8496256
commit 563ffaf894

View File

@ -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
{ {