From c3f79d1e69062304aeef234c19b398f1b8056216 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 29 Oct 2024 14:02:59 +1000 Subject: [PATCH] coord/base: allow arbitrary integral types for indexing --- cruft/util/coord/base.hpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cruft/util/coord/base.hpp b/cruft/util/coord/base.hpp index e3c23551..98dc1e10 100644 --- a/cruft/util/coord/base.hpp +++ b/cruft/util/coord/base.hpp @@ -75,11 +75,15 @@ namespace cruft::coord { } // element accessors - constexpr T& operator[] (size_t i)& noexcept { return this->data[i]; } - constexpr T& operator[] (int i)& noexcept { return this->data[i]; } + template + constexpr T& + operator[] (IdxT i)& noexcept + { return this->data[i]; } - constexpr const T& operator[] (size_t i) const& noexcept { return this->data[i]; } - constexpr const T& operator[] (int i) const& noexcept { return this->data[i]; } + template + constexpr const T& + operator[] (IdxT i) const& noexcept + { return this->data[i]; } auto cbegin (void) const { return std::cbegin (this->data); } auto cend (void) const { return std::cend (this->data); }