using type = const T*;
};
+// Raw pointers don't have an operator->() member function, so the
+// second overload will be SFINAEd out in that case. Otherwise, the
+// second is preferred in the partial order for getPointer(_, 0).
+template <class Iterator>
+auto getPointer(const Iterator& it, long) -> decltype(std::addressof(*it)) {
+ return std::addressof(*it);
+}
+template <class Iterator>
+auto getPointer(const Iterator& it, int) -> decltype(it.operator->()) {
+ return it.operator->();
+}
+
template <class Iterator>
class Enumerator {
public:
return *it_;
}
pointer operator->() {
- return std::addressof(**this);
+ return getPointer(it_, 0);
}
// Const Proxy: Force const references.
return *it_;
}
typename MakeConst<pointer>::type operator->() const {
- return std::addressof(**this);
+ return getPointer(it_, 0);
}
private: