|
|
@@ -3,53 +3,64 @@
|
|
|
#include <iterator/facade.h>
|
|
|
#include <iterator/forwards.h>
|
|
|
|
|
|
+#include <iterator/detail/macro.h>
|
|
|
+
|
|
|
namespace iterator {
|
|
|
-template <typename Iter, typename Self>
|
|
|
-class proxy<Iter, Self, std::input_iterator_tag> : public facade<Self> {
|
|
|
+template <typename It, typename Self, typename Cat>
|
|
|
+class proxy : public facade<Self> {
|
|
|
public:
|
|
|
using single_pass_iterator = void;
|
|
|
|
|
|
private:
|
|
|
- Iter impl_;
|
|
|
+ It impl_;
|
|
|
|
|
|
public:
|
|
|
- proxy(Iter impl = {}) : impl_(impl) {}
|
|
|
+ proxy() = default;
|
|
|
+ proxy(It impl) : impl_(impl) {}
|
|
|
template <typename... Args>
|
|
|
proxy(Args &&... args) : impl_(std::forward<Args>(args)...) {}
|
|
|
|
|
|
decltype(auto) dereference() const { return *impl_; }
|
|
|
void increment() { ++impl_; }
|
|
|
bool equal_to(Self const & other) const { return impl_ == other.impl_; }
|
|
|
+ SFINAE(detail::has_sentinel_type_v, bool) at_end() const {
|
|
|
+ return impl() == typename It::sentinel_type();
|
|
|
+ }
|
|
|
|
|
|
protected:
|
|
|
auto & impl() const { return impl_; }
|
|
|
};
|
|
|
|
|
|
-template <typename Iter, typename Self>
|
|
|
-class proxy<Iter, Self, std::forward_iterator_tag> : public facade<Self> {
|
|
|
+template <typename It, typename Self>
|
|
|
+class proxy<It, Self, std::forward_iterator_tag> : public facade<Self> {
|
|
|
private:
|
|
|
- Iter impl_;
|
|
|
+ It impl_;
|
|
|
|
|
|
public:
|
|
|
- proxy(Iter impl = {}) : impl_(impl) {}
|
|
|
+ proxy() = default;
|
|
|
+ proxy(It impl) : impl_(impl) {}
|
|
|
template <typename... Args>
|
|
|
proxy(Args &&... args) : impl_(std::forward<Args>(args)...) {}
|
|
|
|
|
|
decltype(auto) dereference() const { return *impl_; }
|
|
|
void increment() { ++impl_; }
|
|
|
bool equal_to(Self const & other) const { return impl_ == other.impl_; }
|
|
|
+ SFINAE(detail::has_sentinel_type_v, bool) at_end() const {
|
|
|
+ return impl() == typename It::sentinel_type();
|
|
|
+ }
|
|
|
|
|
|
protected:
|
|
|
auto & impl() const { return impl_; }
|
|
|
};
|
|
|
|
|
|
-template <typename Iter, typename Self>
|
|
|
-class proxy<Iter, Self, std::bidirectional_iterator_tag> : public facade<Self> {
|
|
|
+template <typename It, typename Self>
|
|
|
+class proxy<It, Self, std::bidirectional_iterator_tag> : public facade<Self> {
|
|
|
private:
|
|
|
- Iter impl_;
|
|
|
+ It impl_;
|
|
|
|
|
|
public:
|
|
|
- proxy(Iter impl = {}) : impl_(impl) {}
|
|
|
+ proxy() = default;
|
|
|
+ proxy(It impl) : impl_(impl) {}
|
|
|
template <typename... Args>
|
|
|
proxy(Args &&... args) : impl_(std::forward<Args>(args)...) {}
|
|
|
|
|
|
@@ -57,21 +68,25 @@ public:
|
|
|
void increment() { ++impl_; }
|
|
|
void decrement() { --impl_; }
|
|
|
bool equal_to(Self const & other) const { return impl_ == other.impl_; }
|
|
|
+ SFINAE(detail::has_sentinel_type_v, bool) at_end() const {
|
|
|
+ return impl() == typename It::sentinel_type();
|
|
|
+ }
|
|
|
|
|
|
protected:
|
|
|
auto & impl() const { return impl_; }
|
|
|
};
|
|
|
|
|
|
-template <typename Iter, typename Self>
|
|
|
-class proxy<Iter, Self, std::random_access_iterator_tag> : public facade<Self> {
|
|
|
+template <typename It, typename Self>
|
|
|
+class proxy<It, Self, std::random_access_iterator_tag> : public facade<Self> {
|
|
|
public:
|
|
|
- using difference_type = typename std::iterator_traits<Iter>::difference_type;
|
|
|
+ using difference_type = typename std::iterator_traits<It>::difference_type;
|
|
|
|
|
|
private:
|
|
|
- Iter impl_;
|
|
|
+ It impl_;
|
|
|
|
|
|
public:
|
|
|
- proxy(Iter impl = {}) : impl_(impl) {}
|
|
|
+ proxy() = default;
|
|
|
+ proxy(It impl) : impl_(impl) {}
|
|
|
template <typename... Args>
|
|
|
proxy(Args &&... args) : impl_(std::forward<Args>(args)...) {}
|
|
|
|
|
|
@@ -83,8 +98,13 @@ public:
|
|
|
difference_type distance_to(Self const & other) const {
|
|
|
return other.impl_ - impl_;
|
|
|
}
|
|
|
+ SFINAE(detail::has_sentinel_type_v, bool) at_end() const {
|
|
|
+ return impl() == typename It::sentinel_type();
|
|
|
+ }
|
|
|
|
|
|
protected:
|
|
|
auto & impl() const { return impl_; }
|
|
|
};
|
|
|
}
|
|
|
+
|
|
|
+#include <iterator/detail/undef.h>
|