Ver código fonte

refactor: allow turning an end_aware_iterator into a range

Sam Jaffe 2 meses atrás
pai
commit
ad54b6d1cc
1 arquivos alterados com 5 adições e 0 exclusões
  1. 5 0
      include/iterator/end_aware_iterator.h

+ 5 - 0
include/iterator/end_aware_iterator.h

@@ -6,6 +6,7 @@
 //
 
 #pragma once
+#include <ranges>
 
 #include <iterator/forwards.h>
 #include <iterator/proxy.h>
@@ -37,6 +38,10 @@ public:
   end_aware_iterator(end_aware_iterator<Ot> const & other)
       : super_t(other.impl()), end_(other.end_) {}
 
+  operator std::ranges::subrange<It>() const {
+    return {super_t::impl(), end()};
+  }
+
   bool at_end() const {
     if constexpr (std::random_access_iterator<It>) {
       return super_t::impl() >= end_;