view: use universal references for return types

Reduces the possibility that we dereference a temporary from the
internal iterators.
This commit is contained in:
Danny Robson 2018-05-08 21:51:09 +10:00
parent 170f9ceb2c
commit 2926776c97

View File

@ -351,21 +351,21 @@ namespace util {
} }
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
constexpr auto& constexpr auto&&
operator[] (size_t idx)& noexcept operator[] (size_t idx) noexcept
{ {
return *std::next (begin (), idx); return *std::next (begin (), idx);
} }
//--------------------------------------------------------------------- //---------------------------------------------------------------------
constexpr auto& constexpr auto&&
operator[] (size_t idx) const& noexcept operator[] (size_t idx) const noexcept
{ {
return *std::next (begin (), idx); return *std::next (begin (), idx);
} }
private: private:
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
BeginT m_begin; BeginT m_begin;