mirror of
https://github.com/monero-project/monero.git
synced 2025-04-11 16:52:01 +00:00
epee: span::operator[] allow mut ref from const span
Changes the `operator[]` method so we can get mutable references to elements even if the span is `const`. The operator is now also `constexpr`. This behavior matches `std::span`. C++ standard reference: https://en.cppreference.com/w/cpp/container/span/operator_at
This commit is contained in:
parent
83ae95c4c9
commit
84ff34d299
1 changed files with 1 additions and 2 deletions
|
@ -109,8 +109,7 @@ namespace epee
|
|||
constexpr std::size_t size() const noexcept { return len; }
|
||||
constexpr std::size_t size_bytes() const noexcept { return size() * sizeof(value_type); }
|
||||
|
||||
T &operator[](size_t idx) noexcept { return ptr[idx]; }
|
||||
const T &operator[](size_t idx) const noexcept { return ptr[idx]; }
|
||||
constexpr T &operator[](size_t idx) const noexcept { return ptr[idx]; }
|
||||
|
||||
private:
|
||||
T* ptr;
|
||||
|
|
Loading…
Reference in a new issue