Skip to content

Commit

Permalink
Add subscript operator to strong type
Browse files Browse the repository at this point in the history
  • Loading branch information
atreiber94 authored and reneme committed Jan 2, 2024
1 parent dddcd3b commit fac04ab
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/lib/utils/strong_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ class Strong_Adapter<T> : public Strong_Base<T> {
{
this->get().resize(size);
}

decltype(auto) operator[](size_type i) const noexcept(noexcept(this->get().operator[](i))) {
return this->get()[i];
}

decltype(auto) operator[](size_type i) noexcept(noexcept(this->get().operator[](i))) { return this->get()[i]; }
};

} // namespace detail
Expand Down Expand Up @@ -572,6 +578,8 @@ class StrongSpan {

decltype(auto) end() const noexcept(noexcept(this->m_span.end())) { return this->m_span.end(); }

decltype(auto) operator[](typename underlying_span::size_type i) const noexcept { return this->m_span[i]; }

private:
underlying_span m_span;
};
Expand Down

0 comments on commit fac04ab

Please sign in to comment.