view: prefer std::next over std::advance

next is slightly less likely to trigger issues dereferencing a temporary
(since we aren't producing an lvalue).
This commit is contained in:
Danny Robson 2018-05-08 21:49:27 +10:00
parent e7c108c770
commit 34fc834a29
2 changed files with 3 additions and 9 deletions

View File

@ -80,9 +80,7 @@ namespace util {
iterator operator+ (int count)
{
auto next = *this;
std::advance (next, count);
return next;
return std::next (*this, count);
}
const range_type& operator* (void) const

View File

@ -356,18 +356,14 @@ namespace util {
constexpr auto&
operator[] (size_t idx)& noexcept
{
auto it = begin ();
std::advance (it, idx);
return *it;
return *std::next (begin (), idx);
}
//---------------------------------------------------------------------
constexpr auto&
operator[] (size_t idx) const& noexcept
{
auto it = begin ();
std::advance (it, idx);
return *it;
return *std::next (begin (), idx);
}
private: