mirror of
https://github.com/monero-project/monero.git
synced 2025-12-09 08:31:28 +09: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
@ -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…
x
Reference in New Issue
Block a user