Преглед на файлове

refactor: loosen some concepts

Sam Jaffe преди 2 месеца
родител
ревизия
c9d452e5e3
променени са 2 файла, в които са добавени 7 реда и са изтрити 3 реда
  1. 6 2
      include/iterator/concepts.h
  2. 1 1
      include/iterator/recursive_iterator.h

+ 6 - 2
include/iterator/concepts.h

@@ -11,6 +11,8 @@
 #include <concepts>
 #include <ranges>
 #include <string_view>
+#include <tuple>
+#include <type_traits>
 
 namespace iterator {
 template <typename It>
@@ -106,10 +108,12 @@ template <typename C>
 concept Range = (not String<C>) && std::ranges::range<C>;
 
 template <typename V>
-concept Assoc = std::is_const_v<typename V::first_type>;
+concept Assoc =
+    std::is_const_v<std::remove_reference_t<std::tuple_element_t<0, V>>>;
 
 template <typename V>
-concept AssocRange = Assoc<V> && Range<typename V::second_type>;
+concept AssocRange = Assoc<V> && (std::tuple_size_v<V> == 2) &&
+                     Range<std::decay_t<std::tuple_element_t<1, V>>>;
 
 template <typename C>
 using iterator_t = decltype(std::begin(std::declval<C &>()));

+ 1 - 1
include/iterator/recursive_iterator.h

@@ -22,7 +22,7 @@ namespace iterator {
 template <typename... Ts>
 using tuple_cat_t = decltype(std::tuple_cat(std::declval<Ts>()...));
 
-template <typename It, typename MaxDepth = unbounded, size_t N = 0,
+template <typename It, typename MaxDepth, size_t N = 0,
           typename V = std::iter_value_t<It>>
 struct tuple_expander {
   using iterator_tuple = std::tuple<end_aware_iterator<It>>;