Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove_const from value_type of Range::value_type #2255

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions folly/Range.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,7 @@ class Range {
using size_type = std::size_t;
using iterator = Iter;
using const_iterator = Iter;
using value_type = typename std::remove_reference<
typename std::iterator_traits<Iter>::reference>::type;
using value_type = typename std::iterator_traits<Iter>::value_type;
using difference_type = typename std::iterator_traits<Iter>::difference_type;
using reference = typename std::iterator_traits<Iter>::reference;

Expand Down Expand Up @@ -592,11 +591,11 @@ class Range {
constexpr Iter end() const { return e_; }
constexpr Iter cbegin() const { return b_; }
constexpr Iter cend() const { return e_; }
value_type& front() {
reference front() {
assert(b_ < e_);
return *b_;
}
value_type& back() {
reference back() {
assert(b_ < e_);
return *std::prev(e_);
}
Expand Down Expand Up @@ -745,7 +744,8 @@ class Range {
return r;
}

value_type& operator[](size_t i) {
std::enable_if_t<!std::is_const<reference>::value, reference>
operator[](size_t i) {
assert(i < size());
return b_[i];
}
Expand All @@ -755,7 +755,8 @@ class Range {
return b_[i];
}

value_type& at(size_t i) {
std::enable_if_t<!std::is_const<reference>::value, reference>
at(size_t i) {
if (i >= size()) {
throw_exception<std::out_of_range>("index out of range");
}
Expand Down
Loading