coord/base: allow arbitrary integral types for indexing

This commit is contained in:
Danny Robson 2024-10-29 14:02:59 +10:00
parent 5718506b1d
commit c3f79d1e69

View File

@ -75,11 +75,15 @@ namespace cruft::coord {
} }
// element accessors // element accessors
constexpr T& operator[] (size_t i)& noexcept { return this->data[i]; } template <typename IdxT>
constexpr T& operator[] (int i)& noexcept { return this->data[i]; } constexpr T&
operator[] (IdxT i)& noexcept
{ return this->data[i]; }
constexpr const T& operator[] (size_t i) const& noexcept { return this->data[i]; } template <typename IdxT>
constexpr const T& operator[] (int i) const& noexcept { return this->data[i]; } constexpr const T&
operator[] (IdxT i) const& noexcept
{ return this->data[i]; }
auto cbegin (void) const { return std::cbegin (this->data); } auto cbegin (void) const { return std::cbegin (this->data); }
auto cend (void) const { return std::cend (this->data); } auto cend (void) const { return std::cend (this->data); }