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&
|
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;
|
||||||
|
Loading…
Reference in New Issue
Block a user