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:
parent
e7c108c770
commit
34fc834a29
@ -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
|
||||
|
8
view.hpp
8
view.hpp
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user