Sfoglia il codice sorgente

Extending 98cf896 to support nested containers where the only associative container exists at the final layer.
This should allow joining_iterator to be redundancied, pending ability to get copies of underlying iterators.

Samuel Jaffe 9 anni fa
parent
commit
82eb5b08be
2 ha cambiato i file con 4 aggiunte e 2 eliminazioni
  1. 2 0
      recursive_iterator.hpp
  2. 2 2
      recursive_iterator_mixed_container.t.h

+ 2 - 0
recursive_iterator.hpp

@@ -180,6 +180,7 @@ namespace iterator {
       using next_layer = bounded_recursive_iterator_impl< value_iterator<Iterator>, N+1, Max >;
       using super = recursive_iterator_layer< Iterator, next_layer >;
     public:
+      auto operator*() -> decltype(*(next_layer&)(*this)) { return next_layer::operator*(); }
       using super::super;
     };
     
@@ -201,6 +202,7 @@ namespace iterator {
       using next_layer = recursive_iterator_impl< value_iterator<Iterator> >;
       using super = recursive_iterator_layer< Iterator, next_layer >;
     public:
+      auto operator*() -> decltype(*(next_layer&)(*this)) { return next_layer::operator*(); }
       using super::super;
     };
     

+ 2 - 2
recursive_iterator_mixed_container.t.h

@@ -39,7 +39,7 @@ public:
   
   void test_vector_map_iterator_matches_size() {
     std::vector<std::map<int, int>> const obj{{{1, 1}, {2, 2}}, {{3, 3}, {4, 4}, {5, 5}}};
-    std::vector<std::tuple<int, int>> const expected{{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}};
+    std::vector<std::pair<int const, int>> const expected{{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}};
     auto rit = make_recursive_iterator(obj);
     decltype(rit) end{ };
     TS_ASSERT_EQUALS(std::distance(rit, end), expected.size());
@@ -47,7 +47,7 @@ public:
   
   void test_vector_map_iterator_matches_data() {
     std::vector<std::map<int, int>> const obj{{{1, 1}, {2, 2}}, {{3, 3}, {4, 4}, {5, 5}}};
-    std::vector<std::tuple<int, int>> const expected{{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}};
+    std::vector<std::pair<int const, int>> const expected{{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}};
     auto rit = make_recursive_iterator(obj);
     for (auto it = expected.begin(), end = expected.end(); it != end; ++it, ++rit) {
       TS_ASSERT_EQUALS(*it, *rit);