Commit 91bc2fbe authored by Giuseppe Ottaviano's avatar Giuseppe Ottaviano Committed by Facebook Github Bot

Replace value_before with std::prev

Summary:
`value_before` looks like a pre-C++11 artifact, replace with `std::prev`.

(Note: this ignores all push blocking failures!)

Reviewed By: yfeldblum

Differential Revision: D13852269

fbshipit-source-id: c2e4e8178754a694650f53633f099d05da4127d7
parent a238a687
......@@ -112,32 +112,6 @@ inline size_t qfind_first_of(
*/
namespace detail {
/**
* For random-access iterators, the value before is simply i[-1].
*/
template <class Iter>
typename std::enable_if<
std::is_same<
typename std::iterator_traits<Iter>::iterator_category,
std::random_access_iterator_tag>::value,
typename std::iterator_traits<Iter>::reference>::type
value_before(Iter i) {
return i[-1];
}
/**
* For all other iterators, we need to use the decrement operator.
*/
template <class Iter>
typename std::enable_if<
!std::is_same<
typename std::iterator_traits<Iter>::iterator_category,
std::random_access_iterator_tag>::value,
typename std::iterator_traits<Iter>::reference>::type
value_before(Iter i) {
return *--i;
}
/*
* Use IsCharPointer<T>::type to enable const char* or char*.
* Use IsCharPointer<T>::const_type to enable only const char*.
......@@ -485,7 +459,7 @@ class Range {
}
value_type& back() {
assert(b_ < e_);
return detail::value_before(e_);
return *std::prev(e_);
}
const value_type& front() const {
assert(b_ < e_);
......@@ -493,7 +467,7 @@ class Range {
}
const value_type& back() const {
assert(b_ < e_);
return detail::value_before(e_);
return *std::prev(e_);
}
private:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment