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&
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;