Remove a dead comment in folly/test/SynchronizedTest.cpp
[folly.git] / folly / Enumerate.h
index 2a2ce2201f79726b67a6958ac8b6d71602946c53..f4fb12bebaec79a23e9b5b21037ce5422c7ff800 100644 (file)
@@ -108,15 +108,20 @@ class Enumerator {
     return *this;
   }
 
-  bool operator==(const Enumerator& rhs) {
+  template <typename OtherIterator>
+  bool operator==(const Enumerator<OtherIterator>& rhs) {
     return it_ == rhs.it_;
   }
 
-  bool operator!=(const Enumerator& rhs) {
+  template <typename OtherIterator>
+  bool operator!=(const Enumerator<OtherIterator>& rhs) {
     return !(*this == rhs);
   }
 
  private:
+  template <typename OtherIterator>
+  friend class Enumerator;
+
   Iterator it_;
   size_t idx_ = 0;
 };
@@ -124,16 +129,17 @@ class Enumerator {
 template <class Range>
 class RangeEnumerator {
   Range r_;
-  using Iterator = decltype(r_.begin());
+  using BeginIteratorType = decltype(std::declval<Range>().begin());
+  using EndIteratorType = decltype(std::declval<Range>().end());
 
  public:
   explicit RangeEnumerator(Range&& r) : r_(std::forward<Range>(r)) {}
 
-  Enumerator<Iterator> begin() {
-    return Enumerator<Iterator>(r_.begin());
+  Enumerator<BeginIteratorType> begin() {
+    return Enumerator<BeginIteratorType>(r_.begin());
   }
-  Enumerator<Iterator> end() {
-    return Enumerator<Iterator>(r_.end());
+  Enumerator<EndIteratorType> end() {
+    return Enumerator<EndIteratorType>(r_.end());
   }
 };