From: Christopher Dykes Date: Tue, 26 Jul 2016 22:48:54 +0000 (-0700) Subject: Make RangeEnumerator C++17 compliant (Generalizing the Range-Based For Loop) X-Git-Tag: v2016.07.29.00~15 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=9982d892aa81516bb737ceb97879e7a8b35f4b05;p=folly.git Make RangeEnumerator C++17 compliant (Generalizing the Range-Based For Loop) Summary: Specifically the loosening of the definition of a range where-by the end of an iterator may be represented by a different type than the beginning of the range. Oh, and it also fixes compilation on MSVC, which didn't like the decltype being used to determine the iterator type. Reviewed By: yfeldblum Differential Revision: D3613993 fbshipit-source-id: 2940a15d0f93c5b6310d0b1896f5d12ca9aec639 --- diff --git a/folly/Enumerate.h b/folly/Enumerate.h index 2a2ce220..5733bfb6 100644 --- a/folly/Enumerate.h +++ b/folly/Enumerate.h @@ -124,16 +124,17 @@ class Enumerator { template class RangeEnumerator { Range r_; - using Iterator = decltype(r_.begin()); + using BeginIteratorType = decltype(std::declval().begin()); + using EndIteratorType = decltype(std::declval().end()); public: explicit RangeEnumerator(Range&& r) : r_(std::forward(r)) {} - Enumerator begin() { - return Enumerator(r_.begin()); + Enumerator begin() { + return Enumerator(r_.begin()); } - Enumerator end() { - return Enumerator(r_.end()); + Enumerator end() { + return Enumerator(r_.end()); } };