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)
|
iterator operator+ (int count)
|
||||||
{
|
{
|
||||||
auto next = *this;
|
return std::next (*this, count);
|
||||||
std::advance (next, count);
|
|
||||||
return next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const range_type& operator* (void) const
|
const range_type& operator* (void) const
|
||||||
|
8
view.hpp
8
view.hpp
@ -356,18 +356,14 @@ namespace util {
|
|||||||
constexpr auto&
|
constexpr auto&
|
||||||
operator[] (size_t idx)& noexcept
|
operator[] (size_t idx)& noexcept
|
||||||
{
|
{
|
||||||
auto it = begin ();
|
return *std::next (begin (), idx);
|
||||||
std::advance (it, idx);
|
|
||||||
return *it;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
constexpr auto&
|
constexpr auto&
|
||||||
operator[] (size_t idx) const& noexcept
|
operator[] (size_t idx) const& noexcept
|
||||||
{
|
{
|
||||||
auto it = begin ();
|
return *std::next (begin (), idx);
|
||||||
std::advance (it, idx);
|
|
||||||
return *it;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user