Parcourir la source

refactor: allow turning an end_aware_iterator into a range

Sam Jaffe il y a 2 mois
Parent
commit
ad54b6d1cc
1 fichiers modifiés avec 5 ajouts et 0 suppressions
  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_;