view: use universal references for return types
Reduces the possibility that we dereference a temporary from the internal iterators.
This commit is contained in:
parent
170f9ceb2c
commit
2926776c97
10
view.hpp
10
view.hpp
@ -351,21 +351,21 @@ namespace util {
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
constexpr auto&
|
||||
operator[] (size_t idx)& noexcept
|
||||
constexpr auto&&
|
||||
operator[] (size_t idx) noexcept
|
||||
{
|
||||
return *std::next (begin (), idx);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
constexpr auto&
|
||||
operator[] (size_t idx) const& noexcept
|
||||
constexpr auto&&
|
||||
operator[] (size_t idx) const noexcept
|
||||
{
|
||||
return *std::next (begin (), idx);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
BeginT m_begin;
|
||||
|
Loading…
Reference in New Issue
Block a user