mirror of
https://github.com/monero-project/monero.git
synced 2025-08-22 08:09:36 -04: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
f90a267fa3
commit
332d92ffbe
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…
Add table
Add a link
Reference in a new issue