浏览代码

Apply clang-format.

Sam Jaffe 5 年之前
父节点
当前提交
c95ca71875

+ 108 - 0
.clang-format

@@ -0,0 +1,108 @@
+---
+Language:        Cpp
+# BasedOnStyle:  LLVM
+AccessModifierOffset: -2
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
+AlignEscapedNewlines: Right
+AlignOperands:   true
+AlignTrailingComments: true
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowShortBlocksOnASingleLine: true
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: All
+AllowShortIfStatementsOnASingleLine: true
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: false
+BinPackArguments: true
+BinPackParameters: true
+BraceWrapping:   
+  AfterClass:      false
+  AfterControlStatement: false
+  AfterEnum:       false
+  AfterFunction:   false
+  AfterNamespace:  false
+  AfterObjCDeclaration: false
+  AfterStruct:     false
+  AfterUnion:      false
+  BeforeCatch:     false
+  BeforeElse:      false
+  IndentBraces:    false
+  SplitEmptyFunction: true
+  SplitEmptyRecord: true
+  SplitEmptyNamespace: true
+BreakBeforeBinaryOperators: None
+BreakBeforeBraces: Attach
+BreakBeforeInheritanceComma: false
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializersBeforeComma: false
+BreakConstructorInitializers: BeforeColon
+BreakAfterJavaFieldAnnotations: false
+BreakStringLiterals: true
+ColumnLimit:     80
+CommentPragmas:  '^ IWYU pragma:'
+CompactNamespaces: true
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+ConstructorInitializerIndentWidth: 4
+ContinuationIndentWidth: 4
+Cpp11BracedListStyle: true
+DerivePointerAlignment: false
+DisableFormat:   false
+ExperimentalAutoDetectBinPacking: false
+FixNamespaceComments: false
+ForEachMacros:   
+  - foreach
+  - Q_FOREACH
+  - BOOST_FOREACH
+IncludeCategories: 
+  - Regex:           '^"(llvm|llvm-c|clang|clang-c)/'
+    Priority:        2
+  - Regex:           '^(<|"(gtest|gmock|isl|json)/)'
+    Priority:        3
+  - Regex:           '.*'
+    Priority:        1
+IncludeIsMainRegex: '(Test)?$'
+IndentCaseLabels: false
+IndentWidth:     2
+IndentWrappedFunctionNames: false
+JavaScriptQuotes: Leave
+JavaScriptWrapImports: true
+KeepEmptyLinesAtTheStartOfBlocks: true
+MacroBlockBegin: ''
+MacroBlockEnd:   ''
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: All
+ObjCBlockIndentWidth: 2
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: true
+PenaltyBreakAssignment: 2
+PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakComment: 300
+PenaltyBreakFirstLessLess: 120
+PenaltyBreakString: 1000
+PenaltyExcessCharacter: 1000000
+PenaltyReturnTypeOnItsOwnLine: 60
+PointerAlignment: Middle
+ReflowComments:  true
+SortIncludes:    true
+SortUsingDeclarations: true
+SpaceAfterCStyleCast: false
+SpaceAfterTemplateKeyword: true
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeParens: ControlStatements
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles:  false
+SpacesInContainerLiterals: true
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+Standard:        Cpp11
+TabWidth:        8
+UseTab:          Never
+...
+

+ 21 - 23
include/iterator/end_aware_iterator.hpp

@@ -18,61 +18,62 @@ namespace iterator {
    *
    * @tparam Iterator The underlying iterator type
    */
-  template <typename Iterator>
-  class end_aware_iterator {
+  template <typename Iterator> class end_aware_iterator {
   public:
     using iter_type = Iterator;
     using value_type = typename std::iterator_traits<iter_type>::value_type;
     using reference = typename std::iterator_traits<iter_type>::reference;
     using pointer = typename std::iterator_traits<iter_type>::pointer;
-    using difference_type = typename std::iterator_traits<iter_type>::difference_type;
+    using difference_type =
+        typename std::iterator_traits<iter_type>::difference_type;
     using iterator_category = std::forward_iterator_tag;
+
   public:
     end_aware_iterator() = default;
     end_aware_iterator(iter_type it, iter_type end) : curr_(it), end_(end) {}
     end_aware_iterator(iter_type end) : curr_(end), end_(end) {}
-    
+
     template <typename I>
-    end_aware_iterator( end_aware_iterator<I> const & other )
-    : curr_(other.current()), end_(other.end()) {
-      
-    }
-    
+    end_aware_iterator(end_aware_iterator<I> const & other)
+        : curr_(other.current()), end_(other.end()) {}
+
     end_aware_iterator & operator++() {
-      if ( !done() ) { ++curr_; }
+      if (!done()) { ++curr_; }
       return *this;
     }
-    
+
     end_aware_iterator operator++(int) {
       end_aware_iterator tmp{*this};
       operator++();
       return tmp;
     }
-    
+
     reference operator*() const { return *curr_; }
     pointer operator->() const { return std::addressof(*curr_); }
-    
+
     bool done() const { return curr_ == end_; }
     /**
-     * When comparing iterators that do not point to the same collection/range, 
+     * When comparing iterators that do not point to the same collection/range,
      * the result is not specified by the standard. Therefore, as a matter of
      * convenience, even if the underlying data is different, all end-aware
      * iterators in the done() state are considered equal.
      *
      * @see done
-     * @return true if both iterators are done, or if the underlying iterators 
+     * @return true if both iterators are done, or if the underlying iterators
      * are logically equal
      */
     bool operator==(end_aware_iterator const & other) const {
-      return (done() && other.done()) || (curr_ == other.curr_ && end_ == other.end_);
+      return (done() && other.done()) ||
+             (curr_ == other.curr_ && end_ == other.end_);
     }
-    
+
     bool operator!=(end_aware_iterator const & other) {
       return !(operator==(other));
     }
-    
+
     iter_type current() const { return curr_; }
     iter_type end() const { return end_; }
+
   private:
     iter_type curr_, end_;
   };
@@ -83,13 +84,10 @@ iterator::end_aware_iterator<Iter> make_end_aware_iterator(Iter a, Iter b) {
   return iterator::end_aware_iterator<Iter>(a, b);
 }
 
-template <typename C>
-auto make_end_aware_iterator(C & collect) {
+template <typename C> auto make_end_aware_iterator(C & collect) {
   return make_end_aware_iterator(std::begin(collect), std::end(collect));
 }
 
-template <typename C>
-auto make_end_aware_iterator(C const & collect) {
+template <typename C> auto make_end_aware_iterator(C const & collect) {
   return make_end_aware_iterator(std::begin(collect), std::end(collect));
 }
-

+ 21 - 12
include/iterator/filter_iterator.hpp

@@ -16,52 +16,61 @@ namespace iterator {
   class filter_iterator : public end_aware_iterator<Iter> {
   private:
     using super = end_aware_iterator<Iter>;
+
   public:
     using value_type = typename super::value_type;
     using reference = typename super::reference;
     using pointer = typename super::pointer;
     using difference_type = typename super::difference_type;
     using iterator_category = typename super::iterator_category;
+
   public:
     filter_iterator() = default;
     template <typename... Args>
-    filter_iterator(std::function<bool(value_type const &)> && p, Args &&... super_args)
-    : super(std::forward<Args>(super_args)...)
-    , pred(std::move(p)) {
+    filter_iterator(std::function<bool(value_type const &)> && p,
+                    Args &&... super_args)
+        : super(std::forward<Args>(super_args)...), pred(std::move(p)) {
       if (should_advance()) { advance(); }
     }
-    
+
     filter_iterator & operator++() {
       advance();
       return *this;
     }
-    
+
     filter_iterator operator++(int) {
       filter_iterator tmp{*this};
       operator++();
       return tmp;
     }
+
   private:
     bool should_advance() {
       return !super::done() && !pred(super::operator*());
     }
     void advance() {
-      do { super::operator++(); } while (should_advance());
+      do {
+        super::operator++();
+      } while (should_advance());
     }
     std::function<bool(value_type const &)> pred;
   };
 }
 
 template <typename Pred, typename Iter>
-iterator::filter_iterator<Iter> make_filter_iterator(Pred && p, Iter it, Iter end) { return {p, it, end}; }
+iterator::filter_iterator<Iter> make_filter_iterator(Pred && p, Iter it,
+                                                     Iter end) {
+  return {p, it, end};
+}
 
 template <typename Pred, typename C>
-auto make_filter_iterator(Pred && p, C & collect) -> iterator::filter_iterator<decltype(std::begin(collect))> {
-  return { p, std::begin(collect), std::end(collect) };
+auto make_filter_iterator(Pred && p, C & collect)
+    -> iterator::filter_iterator<decltype(std::begin(collect))> {
+  return {p, std::begin(collect), std::end(collect)};
 }
 
 template <typename Pred, typename C>
-auto make_filter_iterator(Pred && p, C const & collect) -> iterator::filter_iterator<decltype(std::begin(collect))> {
-  return { p, std::begin(collect), std::end(collect) };
+auto make_filter_iterator(Pred && p, C const & collect)
+    -> iterator::filter_iterator<decltype(std::begin(collect))> {
+  return {p, std::begin(collect), std::end(collect)};
 }
-

+ 72 - 30
include/iterator/indexed_iterator.hpp

@@ -10,48 +10,90 @@
 #include <iterator>
 
 namespace iterator {
-  template <typename Iterator>
-  class indexed_iterator {
+  template <typename Iterator> class indexed_iterator {
   private:
     using base_value_type = typename std::iterator_traits<Iterator>::value_type;
     using base_reference = typename std::iterator_traits<Iterator>::reference;
+
   public:
     using index_type = std::size_t;
     using value_type = std::pair<index_type, base_value_type>;
     using reference = std::pair<index_type, base_reference>;
     using pointer = void;
-    using difference_type = typename std::iterator_traits<Iterator>::difference_type;
-    using iterator_category = typename std::iterator_traits<Iterator>::iterator_category;
-    
+    using difference_type =
+        typename std::iterator_traits<Iterator>::difference_type;
+    using iterator_category =
+        typename std::iterator_traits<Iterator>::iterator_category;
+
     indexed_iterator() : _base(), _index(0) {}
-    indexed_iterator(Iterator base, index_type idx = 0) : _base(base), _index(idx) {}
-    
+    indexed_iterator(Iterator base, index_type idx = 0)
+        : _base(base), _index(idx) {}
+
     template <typename OtherIterator>
-    indexed_iterator(indexed_iterator<OtherIterator> const & oiter) :
-    _base(oiter._base), _index(oiter._index) {
-      
-    }
-    
-    reference operator*() const { return reference{ _index, *_base }; }
-    
-    indexed_iterator & operator++() { ++_base; ++_index; return *this; }
-    indexed_iterator operator++(int) { indexed_iterator tmp{*this}; operator++(); return tmp; }
-    bool operator==(indexed_iterator const & other) const { return _base == other._base; }
-    bool operator!=(indexed_iterator const & other) const { return _base != other._base; }
-    
+    indexed_iterator(indexed_iterator<OtherIterator> const & oiter)
+        : _base(oiter._base), _index(oiter._index) {}
+
+    reference operator*() const { return reference{_index, *_base}; }
+
+    indexed_iterator & operator++() {
+      ++_base;
+      ++_index;
+      return *this;
+    }
+    indexed_iterator operator++(int) {
+      indexed_iterator tmp{*this};
+      operator++();
+      return tmp;
+    }
+    bool operator==(indexed_iterator const & other) const {
+      return _base == other._base;
+    }
+    bool operator!=(indexed_iterator const & other) const {
+      return _base != other._base;
+    }
+
     // Requires: iterator_category = bidirectional_iterator_tag
-    indexed_iterator & operator--() { --_base; --_index; return *this; }
-    indexed_iterator operator--(int) { indexed_iterator tmp{*this}; operator--(); return tmp; }
-    
+    indexed_iterator & operator--() {
+      --_base;
+      --_index;
+      return *this;
+    }
+    indexed_iterator operator--(int) {
+      indexed_iterator tmp{*this};
+      operator--();
+      return tmp;
+    }
+
     // Requires: iterator_category = random_access_iterator_tag
-    indexed_iterator operator+(difference_type n) const { return indexed_iterator{*this} += n; }
-    indexed_iterator & operator+=(difference_type n) { _index += n; _base += n; return *this; }
-    indexed_iterator operator-(difference_type n) const { return indexed_iterator{*this} -= n; }
-    indexed_iterator & operator-=(difference_type n) { _index -= n; _base -= n;return *this; }
-    bool operator<=(indexed_iterator const & other) const { return _base <= other._base; }
-    bool operator< (indexed_iterator const & other) const { return _base <  other._base; }
-    bool operator>=(indexed_iterator const & other) const { return _base >= other._base; }
-    bool operator> (indexed_iterator const & other) const { return _base >  other._base; }
+    indexed_iterator operator+(difference_type n) const {
+      return indexed_iterator{*this} += n;
+    }
+    indexed_iterator & operator+=(difference_type n) {
+      _index += n;
+      _base += n;
+      return *this;
+    }
+    indexed_iterator operator-(difference_type n) const {
+      return indexed_iterator{*this} -= n;
+    }
+    indexed_iterator & operator-=(difference_type n) {
+      _index -= n;
+      _base -= n;
+      return *this;
+    }
+    bool operator<=(indexed_iterator const & other) const {
+      return _base <= other._base;
+    }
+    bool operator<(indexed_iterator const & other) const {
+      return _base < other._base;
+    }
+    bool operator>=(indexed_iterator const & other) const {
+      return _base >= other._base;
+    }
+    bool operator>(indexed_iterator const & other) const {
+      return _base > other._base;
+    }
+
   private:
     template <typename It> friend class ::iterator::indexed_iterator;
     Iterator _base;

+ 7 - 5
include/iterator/iterator_fwd.hpp

@@ -16,14 +16,16 @@ namespace iterator {
 
     template <typename IterType>
     using value_iterator = decltype(std::begin(*std::declval<IterType>()));
-    
+
     template <typename IterType>
-    using mapped_iterator = decltype(std::begin(std::declval<IterType>()->second));
+    using mapped_iterator =
+        decltype(std::begin(std::declval<IterType>()->second));
   }
-  
-  struct {} in_place;
+
+  struct {
+  } in_place;
   using in_place_t = decltype(in_place);
-  
+
   template <typename Iterator> class end_aware_iterator;
   template <typename MetaIterator> class joining_iterator;
   template <typename Iterator> class recursive_iterator;

+ 29 - 27
include/iterator/join_iterator.hpp

@@ -7,76 +7,78 @@
 
 #pragma once
 
-#include "iterator_fwd.hpp"
 #include "end_aware_iterator.hpp"
+#include "iterator_fwd.hpp"
 
 #include <iterator>
 
 namespace iterator {
-  template <typename MetaIterator>
-  class joining_iterator {
+  template <typename MetaIterator> class joining_iterator {
   public:
     using join_iter = MetaIterator;
     using joinable_type = typename join_iter::value_type;
     using iter_type = detail::value_iterator<MetaIterator>;
-    
+
     using value_type = typename std::iterator_traits<iter_type>::value_type;
     using reference = typename std::iterator_traits<iter_type>::reference;
     using pointer = typename std::iterator_traits<iter_type>::pointer;
-    using difference_type = typename std::iterator_traits<iter_type>::difference_type;
+    using difference_type =
+        typename std::iterator_traits<iter_type>::difference_type;
     using iterator_category = std::forward_iterator_tag;
+
   public:
-    explicit joining_iterator( ) = default;
-    
+    explicit joining_iterator() = default;
+
     template <typename I>
-    joining_iterator( joining_iterator<I> const & other )
-    : joiner_(other.join_iterator()), iterator_(other.element_iterator()) {
-      
-    }
-    
-    joining_iterator( end_aware_iterator<join_iter> join ) : joining_iterator(join, {}, true) {}
-    joining_iterator( end_aware_iterator<join_iter> join, end_aware_iterator<iter_type> elem, bool update = false )
-    : joiner_(join), iterator_(elem) {
-      if ( update ) { update_iterator(); }
+    joining_iterator(joining_iterator<I> const & other)
+        : joiner_(other.join_iterator()), iterator_(other.element_iterator()) {}
+
+    joining_iterator(end_aware_iterator<join_iter> join)
+        : joining_iterator(join, {}, true) {}
+    joining_iterator(end_aware_iterator<join_iter> join,
+                     end_aware_iterator<iter_type> elem, bool update = false)
+        : joiner_(join), iterator_(elem) {
+      if (update) { update_iterator(); }
     }
-    
+
     joining_iterator & operator++() {
-      if ( (++iterator_).done() ) {
+      if ((++iterator_).done()) {
         ++joiner_;
         update_iterator();
       }
       return *this;
     }
-    
+
     joining_iterator operator++(int) {
       joining_iterator tmp{*this};
       operator++();
       return tmp;
     }
-    
+
     reference operator*() const { return iterator_.operator*(); }
     pointer operator->() const { return iterator_.operator->(); }
-    
+
     bool operator==(joining_iterator const & other) const {
       return joiner_ == other.joiner_ && iterator_ == other.iterator_;
     }
-    
+
     bool operator!=(joining_iterator const & other) {
       return !(operator==(other));
     }
-    
+
     end_aware_iterator<join_iter> join_iterator() const { return joiner_; }
     end_aware_iterator<iter_type> element_iterator() const { return iterator_; }
+
   private:
     void update_iterator() {
-      while ( !joiner_.done() && std::begin(*joiner_) == std::end(*joiner_) ) {
+      while (!joiner_.done() && std::begin(*joiner_) == std::end(*joiner_)) {
         ++joiner_;
       }
-      if ( !joiner_.done() ) {
-        iterator_ = { std::begin(*joiner_), std::end(*joiner_) };
+      if (!joiner_.done()) {
+        iterator_ = {std::begin(*joiner_), std::end(*joiner_)};
       }
     }
-    
+
     end_aware_iterator<join_iter> joiner_;
     end_aware_iterator<iter_type> iterator_;
   };

+ 153 - 110
include/iterator/recursive_iterator.hpp

@@ -9,63 +9,76 @@
 
 #include <tuple>
 
-#include "iterator_fwd.hpp"
 #include "end_aware_iterator.hpp"
+#include "iterator_fwd.hpp"
 
 namespace iterator { namespace detail {
   struct terminal_layer_tag_t;
   struct continue_layer_tag_t;
-  
+
   /**
    * @class recursive_iterator_base
-   * @brief A thin wrapper around end_aware_iterator for the purposes of template metaprogramming.
+   * @brief A thin wrapper around end_aware_iterator for the purposes of
+   * template metaprogramming.
    */
   template <typename Iterator, typename = void>
   class recursive_iterator_base : public end_aware_iterator<Iterator> {
   public:
     using super = end_aware_iterator<Iterator>;
+
   protected:
     using recursive_category = terminal_layer_tag_t;
+
   public:
     using super::super;
     recursive_iterator_base(super const & iter) : super(iter) {}
     recursive_iterator_base(super && iter) : super(std::move(iter)) {}
     recursive_iterator_base() = default;
     operator super() const { return *this; }
+
   protected:
     typename super::reference get() const { return super::operator*(); }
   };
-  
+
   /**
    * @class recursive_iterator_base
-   * @brief An SFINAE specialization of recursive_iterator_base for associative containers
+   * @brief An SFINAE specialization of recursive_iterator_base for associative
+   * containers
    *
    * Because it is possible for recursive iterator to step over multiple layers
    * of associative containers, the return type is made into a tuple, so that
-   * the caller does not need to write something like `it->second.second.second'.
-   * Instead, the return type is a tuple of references, so that the caller can
-   * write code like `std::get<3>(*it)'.
+   * the caller does not need to write something like
+   * `it->second.second.second'. Instead, the return type is a tuple of
+   * references, so that the caller can write code like `std::get<3>(*it)'.
    *
    * For example, the ref type for std::map<int, std::map<float, double> >
    * with this would be std::tuple<int const&, float const&, double &>.
    */
   template <typename Iterator>
-  class recursive_iterator_base<Iterator, typename std::enable_if<std::is_const<typename end_aware_iterator<Iterator>::value_type::first_type>::value>::type> : public end_aware_iterator<Iterator> {
+  class recursive_iterator_base<
+      Iterator,
+      typename std::enable_if<std::is_const<typename end_aware_iterator<
+          Iterator>::value_type::first_type>::value>::type>
+      : public end_aware_iterator<Iterator> {
   public:
     using super = end_aware_iterator<Iterator>;
     using first_type = decltype((std::declval<Iterator>()->first));
     using second_type = decltype((std::declval<Iterator>()->second));
+
   protected:
     using recursive_category = continue_layer_tag_t;
+
   public:
     using value_type = std::tuple<first_type, second_type>;
     using reference = std::tuple<first_type &, second_type &>;
+
   public:
     using super::super;
     recursive_iterator_base(super const & iter) : super(iter) {}
     recursive_iterator_base(super && iter) : super(std::move(iter)) {}
     recursive_iterator_base() = default;
     operator super() const { return *this; }
+
   protected:
     /**
      * An alternative function to operator*(), which allows single layer
@@ -78,10 +91,11 @@ namespace iterator { namespace detail {
       return std::tie(pair.first, pair.second);
     }
   };
-  
+
   /**
    * @class recursive_iterator_layer
-   * @brief A single layer for recursing down a nested collection. Represents non-associative containers.
+   * @brief A single layer for recursing down a nested collection. Represents
+   * non-associative containers.
    *
    * Provides dispatch/overloading for types and functions of recursive_iterator
    * chains to resolve ambiguous typedefs and operators.
@@ -89,23 +103,26 @@ namespace iterator { namespace detail {
    * @see recursive_iterator_impl
    * @see bounded_recursive_iterator_impl
    * @tparam Iterator The underlying iterator type of the layer
-   * @tparam RecursiveIterator_NextLayer The next layer, either a recursive_iterator_impl, or a bounded_recursive_iterator_impl
+   * @tparam RecursiveIterator_NextLayer The next layer, either a
+   * recursive_iterator_impl, or a bounded_recursive_iterator_impl
    */
   template <typename Iterator, typename RecursiveIterator_NextLayer>
-  class recursive_iterator_layer :
-  public recursive_iterator_base< Iterator >,
-  public RecursiveIterator_NextLayer {
+  class recursive_iterator_layer : public recursive_iterator_base<Iterator>,
+                                   public RecursiveIterator_NextLayer {
   public:
     using super = RecursiveIterator_NextLayer;
-    using layer = recursive_iterator_base< Iterator >;
+    using layer = recursive_iterator_base<Iterator>;
+
   protected:
     using recursive_category = continue_layer_tag_t;
+
   public:
     using value_type = typename super::value_type;
     using reference = typename super::reference;
     using pointer = typename super::pointer;
     using difference_type = typename super::difference_type;
     using iterator_category = std::forward_iterator_tag;
+
   public:
     recursive_iterator_layer() = default;
     recursive_iterator_layer(layer v) : recursive_iterator_layer() {
@@ -114,29 +131,26 @@ namespace iterator { namespace detail {
     }
     template <typename OIter, typename Rec>
     recursive_iterator_layer(recursive_iterator_layer<OIter, Rec> const & other)
-        : layer(static_cast<recursive_iterator_base<OIter>const&>(other)),
-          super(static_cast<Rec const&>(other)) {}
+        : layer(static_cast<recursive_iterator_base<OIter> const &>(other)),
+          super(static_cast<Rec const &>(other)) {}
     template <typename OIter, typename... Iterators>
-    recursive_iterator_layer(in_place_t, OIter && it, Iterators && ...iter)
-    : layer(std::forward<OIter>(it)),
-      super(in_place, std::forward<Iterators>(iter)...) {
+    recursive_iterator_layer(in_place_t, OIter && it, Iterators &&... iter)
+        : layer(std::forward<OIter>(it)),
+          super(in_place, std::forward<Iterators>(iter)...) {
       update();
     }
-    
-    reference operator*() const {
-      return super::get();
-    }
-    
-    pointer operator->() const {
-      return super::operator->();
-    }
-    
+
+    reference operator*() const { return super::get(); }
+
+    pointer operator->() const { return super::operator->(); }
+
     bool operator==(recursive_iterator_layer const & other) const {
       return layer::operator==(other) && super::operator==(other);
     }
+
   protected:
     reference get() const { return operator*(); }
-    
+
     /**
      * Advance the iterator step. If the next layer has reached the end, then
      * we advance this iterator until it reaches either its own end, or a
@@ -146,64 +160,74 @@ namespace iterator { namespace detail {
       super::next();
       update();
     }
-    
+
     /**
      * Update the underlying iterator and propogate updates down the chain so
      * that if there is data available, the iterator is in a dereferencable
      * state.
      */
     void assign(layer v) {
-      static_cast<layer&>(*this) = v;
-      if (!v.done()) {
-        super::assign(make_end_aware_iterator(*v));
-      }
+      static_cast<layer &>(*this) = v;
+      if (!v.done()) { super::assign(make_end_aware_iterator(*v)); }
     }
-    
+
     void update() {
-      layer & self = static_cast<layer&>(*this);
-      while ( super::done() && !(++self).done() ) {
+      layer & self = static_cast<layer &>(*this);
+      while (super::done() && !(++self).done()) {
         super::assign(make_end_aware_iterator(*self));
       }
     }
-    
+
     bool done() const { return layer::done(); }
   };
-  
+
   /**
    * @class next_layer_type
-   * @breif A template metaprogramming type for unifying associative and non-associative containers.
+   * @breif A template metaprogramming type for unifying associative and
+   * non-associative containers.
    */
-  template <typename V, typename Tag>
-  struct next_layer_type { using type = std::tuple<V>; };
-  template <typename V>
-  struct next_layer_type<V, continue_layer_tag_t> { using type = V; };
-  
+  template <typename V, typename Tag> struct next_layer_type {
+    using type = std::tuple<V>;
+  };
+  template <typename V> struct next_layer_type<V, continue_layer_tag_t> {
+    using type = V;
+  };
+
   /**
    * @class flatten_iterator_layer
-   * @brief A single layer for recursing down a nested collection. Represents associative containers.
+   * @brief A single layer for recursing down a nested collection. Represents
+   * associative containers.
    *
    * @copydoc recursive_iterator_layer
    */
   template <typename Iterator, typename RecursiveIterator_NextLayer>
-  class flatten_iterator_layer :
-  public recursive_iterator_base< Iterator >,
-  public RecursiveIterator_NextLayer {
+  class flatten_iterator_layer : public recursive_iterator_base<Iterator>,
+                                 public RecursiveIterator_NextLayer {
   public:
     using super = RecursiveIterator_NextLayer;
-    using layer = recursive_iterator_base< Iterator >;
-    using key_type = typename std::tuple_element<0, typename layer::value_type>::type;
+    using layer = recursive_iterator_base<Iterator>;
+    using key_type =
+        typename std::tuple_element<0, typename layer::value_type>::type;
+
   protected:
     using recursive_category = continue_layer_tag_t;
-    using next_value_type = typename next_layer_type<typename super::value_type, typename super::recursive_category>::type;
-    using next_reference = typename next_layer_type<typename super::reference, typename super::recursive_category>::type;
+    using next_value_type =
+        typename next_layer_type<typename super::value_type,
+                                 typename super::recursive_category>::type;
+    using next_reference =
+        typename next_layer_type<typename super::reference,
+                                 typename super::recursive_category>::type;
+
   public:
-    using value_type = decltype(std::tuple_cat(std::make_tuple(std::declval<key_type>()),
-                                               std::declval<next_value_type>()));
-    using reference = decltype(std::tuple_cat(std::tie(std::declval<key_type>()),
-                                              std::declval<next_reference>()));
+    using value_type =
+        decltype(std::tuple_cat(std::make_tuple(std::declval<key_type>()),
+                                std::declval<next_value_type>()));
+    using reference = decltype(std::tuple_cat(
+        std::tie(std::declval<key_type>()), std::declval<next_reference>()));
     using pointer = void;
     using difference_type = typename super::difference_type;
     using iterator_category = std::forward_iterator_tag;
+
   public:
     flatten_iterator_layer() = default;
     flatten_iterator_layer(layer v) : flatten_iterator_layer() {
@@ -211,16 +235,19 @@ namespace iterator { namespace detail {
       update();
     }
     template <typename OIter, typename Rec>
-    flatten_iterator_layer(flatten_iterator_layer<OIter, Rec> const & other) : layer(static_cast<recursive_iterator_base<OIter>const&>(other)), super(static_cast<Rec const&>(other)) {}
+    flatten_iterator_layer(flatten_iterator_layer<OIter, Rec> const & other)
+        : layer(static_cast<recursive_iterator_base<OIter> const &>(other)),
+          super(static_cast<Rec const &>(other)) {}
     template <typename OIter, typename... Iterators>
-    flatten_iterator_layer(in_place_t, OIter && it, Iterators && ...iter)
-    : layer(std::forward<OIter>(it)),
-      super(in_place, std::forward<Iterators>(iter)...) {
+    flatten_iterator_layer(in_place_t, OIter && it, Iterators &&... iter)
+        : layer(std::forward<OIter>(it)),
+          super(in_place, std::forward<Iterators>(iter)...) {
       update();
     }
-    
+
     /**
-     * @brief Concatenate the key in this layer, with the dereferenced data from the next.
+     * @brief Concatenate the key in this layer, with the dereferenced data from
+     * the next.
      *
      * Due to the use of the next_layer_type metaprogramming, a type such as
      * std::map<K, std::vector<std::tuple<T1, T2, T3>>> would return a reference
@@ -232,19 +259,20 @@ namespace iterator { namespace detail {
       return std::tuple_cat(std::forward_as_tuple(std::get<0>(layer::get())),
                             next_reference(super::get()));
     }
-    
+
     /**
      * Unimplemented because we return an inline constructed type, and tuple
      * can only be accessed through std::get anyway.
      */
     pointer operator->() const;
-    
+
     bool operator==(flatten_iterator_layer const & other) const {
       return layer::operator==(other) && super::operator==(other);
     }
+
   protected:
     reference get() const { return operator*(); }
-    
+
     /**
      * @copydoc recursive_iterator_layer::next
      */
@@ -252,34 +280,33 @@ namespace iterator { namespace detail {
       super::next();
       update();
     }
-    
+
     void update() {
-      layer & self = static_cast<layer&>(*this);
-      while ( super::done() && !(++self).done() ) {
+      layer & self = static_cast<layer &>(*this);
+      while (super::done() && !(++self).done()) {
         super::assign(make_end_aware_iterator(self->second));
       }
     }
-    
+
     /**
      * @copydoc recursive_iterator_layer::assign
      */
     void assign(layer v) {
-      static_cast<layer&>(*this) = v;
-      if ( !v.done() ) {
-        super::assign(make_end_aware_iterator(v->second));
-      }
+      static_cast<layer &>(*this) = v;
+      if (!v.done()) { super::assign(make_end_aware_iterator(v->second)); }
     }
-    
+
     bool done() const { return layer::done(); }
   };
-} }
+}}
 
 #include "recursive_iterator_meta.hpp"
 
 namespace iterator {
   /**
    * @class recursive_iterator
-   * @brief An iterator type for nested collections, allowing you to treat it as a single-layer collection.
+   * @brief An iterator type for nested collections, allowing you to treat it as
+   * a single-layer collection.
    *
    * In order to provide a simple interface, if an associative container is used
    * in the chain, the type returned by operator*() is a tuple. If multiple
@@ -290,39 +317,43 @@ namespace iterator {
    * @tparam Iterator The iterator type of the top-level collection.
    */
   template <typename Iterator>
-  class recursive_iterator : public detail::recursive_iterator_impl< Iterator > {
+  class recursive_iterator : public detail::recursive_iterator_impl<Iterator> {
   public:
-    using super = detail::recursive_iterator_impl< Iterator >;
+    using super = detail::recursive_iterator_impl<Iterator>;
+
   public:
     using super::super;
     recursive_iterator() = default;
     template <typename... Iterators>
-    recursive_iterator(in_place_t, Iterators && ...iter)
+    recursive_iterator(in_place_t, Iterators &&... iter)
         : super(in_place, std::forward<Iterators>(iter)...) {}
 
     recursive_iterator & operator++() {
-      (void) super::next();
+      (void)super::next();
       return *this;
     }
-    
+
     recursive_iterator operator++(int) {
       recursive_iterator tmp{*this};
-      (void) super::next();
+      (void)super::next();
       return tmp;
     }
-    
-    bool operator!=(recursive_iterator const & other) { return !(super::operator==(other)); }
+
+    bool operator!=(recursive_iterator const & other) {
+      return !(super::operator==(other));
+    }
   };
-  
+
   /**
    * @class recursive_iterator_n
    * @copydoc recursive_iterator
    * This object has bounded recursive depth, so that it can be used to get
    * sub-collections, which may be used in other functions.
    *
-   * For Example: 
+   * For Example:
    * @code
-   * using map_type = std::map<std::string, std::map<std::string, std::vector<Data> > >;
+   * using map_type = std::map<std::string, std::map<std::string,
+   * std::vector<Data> > >;
    * ...
    * recursive_iterator_n<map_type::iterator, 2> iter{ ... };
    * std::vector<Data> & data = std::get<2>(*iter);
@@ -332,59 +363,71 @@ namespace iterator {
    * @tparam N The maximum depth to recurse into the object
    */
   template <typename Iterator, std::size_t N>
-  class recursive_iterator_n : public detail::bounded_recursive_iterator_impl< Iterator, 1, N > {
+  class recursive_iterator_n
+      : public detail::bounded_recursive_iterator_impl<Iterator, 1, N> {
   public:
-    using super = detail::bounded_recursive_iterator_impl< Iterator, 1, N >;
+    using super = detail::bounded_recursive_iterator_impl<Iterator, 1, N>;
+
   public:
     using super::super;
     recursive_iterator_n() = default;
     template <typename... Iterators>
-    recursive_iterator_n(in_place_t, Iterators && ...iter)
+    recursive_iterator_n(in_place_t, Iterators &&... iter)
         : super(in_place, std::forward<Iterators>(iter)...) {}
-    
+
     recursive_iterator_n & operator++() {
-      (void) super::next();
+      (void)super::next();
       return *this;
     }
-    
+
     recursive_iterator_n operator++(int) {
       recursive_iterator_n tmp{*this};
-      (void) super::next();
+      (void)super::next();
       return tmp;
     }
-    
-    bool operator!=(recursive_iterator_n const & other) { return !(super::operator==(other)); }
+
+    bool operator!=(recursive_iterator_n const & other) {
+      return !(super::operator==(other));
+    }
   };
 }
 
 namespace std {
   template <std::size_t I, typename It>
-  auto get(::iterator::recursive_iterator<It> const & iter) -> typename ::iterator::detail::accessor<I, ::iterator::recursive_iterator<It>>::type {
+  auto get(::iterator::recursive_iterator<It> const & iter) ->
+      typename ::iterator::detail::accessor<
+          I, ::iterator::recursive_iterator<It>>::type {
     return iter;
   }
 }
 
 template <typename Iter0, typename... Iters>
-auto make_recursive_iterator(iterator::end_aware_iterator<Iter0> it, Iters &&... iters) -> iterator::recursive_iterator<Iter0> {
-  return { iterator::in_place, std::move(it), std::forward<Iters>(iters)... };
+auto make_recursive_iterator(iterator::end_aware_iterator<Iter0> it,
+                             Iters &&... iters)
+    -> iterator::recursive_iterator<Iter0> {
+  return {iterator::in_place, std::move(it), std::forward<Iters>(iters)...};
 }
 
 template <typename C>
-auto make_recursive_iterator(C & collect) -> iterator::recursive_iterator<decltype(std::begin(collect))> {
-  return { make_end_aware_iterator(collect)};
+auto make_recursive_iterator(C & collect)
+    -> iterator::recursive_iterator<decltype(std::begin(collect))> {
+  return {make_end_aware_iterator(collect)};
 }
 
 template <typename C>
-auto make_recursive_iterator(C const & collect) -> iterator::recursive_iterator<decltype(std::begin(collect))> {
-  return { make_end_aware_iterator(collect) };
+auto make_recursive_iterator(C const & collect)
+    -> iterator::recursive_iterator<decltype(std::begin(collect))> {
+  return {make_end_aware_iterator(collect)};
 }
 
 template <std::size_t Max, typename C>
-auto make_recursive_iterator(C & collect) -> iterator::recursive_iterator_n<decltype(std::begin(collect)), Max> {
-  return { make_end_aware_iterator(collect) };
+auto make_recursive_iterator(C & collect)
+    -> iterator::recursive_iterator_n<decltype(std::begin(collect)), Max> {
+  return {make_end_aware_iterator(collect)};
 }
 
 template <std::size_t Max, typename C>
-auto make_recursive_iterator(C const & collect) -> iterator::recursive_iterator_n<decltype(std::begin(collect)), Max> {
-  return { make_end_aware_iterator(collect) };
+auto make_recursive_iterator(C const & collect)
+    -> iterator::recursive_iterator_n<decltype(std::begin(collect)), Max> {
+  return {make_end_aware_iterator(collect)};
 }

+ 90 - 58
include/iterator/recursive_iterator_meta.hpp

@@ -8,29 +8,33 @@
 #pragma once
 
 namespace iterator { namespace detail {
-  
+
   /**
    * @class recursive_iterator_impl
-   * @brief The default (terminal) implementation of an unbounded recursive iterator.
+   * @brief The default (terminal) implementation of an unbounded recursive
+   * iterator.
    *
    * @see recursive_iterator_base
-   * @param Iterator The iterator type being processed, such as std::vector<int>::iterator
+   * @param Iterator The iterator type being processed, such as
+   * std::vector<int>::iterator
    */
   template <typename Iterator, typename = void>
-  class recursive_iterator_impl : public recursive_iterator_base< Iterator > {
+  class recursive_iterator_impl : public recursive_iterator_base<Iterator> {
   public:
-    using super = recursive_iterator_base< Iterator >;
+    using super = recursive_iterator_base<Iterator>;
+
   public:
     using super::super;
     recursive_iterator_impl() = default;
     template <typename OIter>
     recursive_iterator_impl(in_place_t, OIter && iter)
         : super(std::forward<OIter>(iter)) {}
+
   protected:
     void next() { super::operator++(); }
-    void assign(super eat) { static_cast<super&>(*this) = eat; }
+    void assign(super eat) { static_cast<super &>(*this) = eat; }
   };
-  
+
   /**
    * @class recursive_iterator_impl
    *
@@ -39,11 +43,14 @@ namespace iterator { namespace detail {
    * @see recursive_iterator_layer
    */
   template <typename Iterator>
-  class recursive_iterator_impl< Iterator, typename void_t<value_iterator<Iterator>>::type > :
-  public recursive_iterator_layer< Iterator, recursive_iterator_impl< value_iterator<Iterator> > > {
+  class recursive_iterator_impl<Iterator,
+                                typename void_t<value_iterator<Iterator>>::type>
+      : public recursive_iterator_layer<
+            Iterator, recursive_iterator_impl<value_iterator<Iterator>>> {
   public:
-    using next_layer = recursive_iterator_impl< value_iterator<Iterator> >;
-    using super = recursive_iterator_layer< Iterator, next_layer >;
+    using next_layer = recursive_iterator_impl<value_iterator<Iterator>>;
+    using super = recursive_iterator_layer<Iterator, next_layer>;
+
   public:
     /**
      * A special override of operator* that allows collections like
@@ -51,14 +58,16 @@ namespace iterator { namespace detail {
      * type of the map. Works only for nested collections with one associative
      * container at the bottom level.
      */
-    auto operator*() const -> decltype(*(next_layer&)(*this)) { return next_layer::operator*(); }
+    auto operator*() const -> decltype(*(next_layer &)(*this)) {
+      return next_layer::operator*();
+    }
     using super::super;
     recursive_iterator_impl() = default;
     template <typename... Iterators>
-    recursive_iterator_impl(in_place_t, Iterators && ...iter)
+    recursive_iterator_impl(in_place_t, Iterators &&... iter)
         : super(in_place, std::forward<Iterators>(iter)...) {}
   };
-  
+
   /**
    * @class recursive_iterator_impl
    *
@@ -67,44 +76,52 @@ namespace iterator { namespace detail {
    * @see flatten_iterator_layer
    */
   template <typename Iterator>
-  class recursive_iterator_impl< Iterator, typename void_t<mapped_iterator<Iterator>>::type > :
-  public flatten_iterator_layer< Iterator, recursive_iterator_impl< mapped_iterator<Iterator> > > {
+  class recursive_iterator_impl<
+      Iterator, typename void_t<mapped_iterator<Iterator>>::type>
+      : public flatten_iterator_layer<
+            Iterator, recursive_iterator_impl<mapped_iterator<Iterator>>> {
   public:
-    using next_layer = recursive_iterator_impl< mapped_iterator<Iterator> >;
-    using super = flatten_iterator_layer< Iterator, next_layer >;
+    using next_layer = recursive_iterator_impl<mapped_iterator<Iterator>>;
+    using super = flatten_iterator_layer<Iterator, next_layer>;
+
   public:
     using super::super;
     recursive_iterator_impl() = default;
     template <typename... Iterators>
-    recursive_iterator_impl(in_place_t, Iterators && ...iter)
+    recursive_iterator_impl(in_place_t, Iterators &&... iter)
         : super(in_place, std::forward<Iterators>(iter)...) {}
   };
-  
+
   /**
    * @class bounded_recursive_iterator_impl
-   * @brief The default (terminal) implementation of a recursive iterator up to Max levels deep.
+   * @brief The default (terminal) implementation of a recursive iterator up to
+   * Max levels deep.
    *
    * @see recursive_iterator_base
-   * @param Iterator The iterator type being processed, such as std::vector<int>::iterator
+   * @param Iterator The iterator type being processed, such as
+   * std::vector<int>::iterator
    * @param N The current layer of depth, starts at 1.
-   * @param Max The maximum recursive depth to dive down, in case you need to process some sub-collection in a specific manner.
+   * @param Max The maximum recursive depth to dive down, in case you need to
+   * process some sub-collection in a specific manner.
    */
   template <typename Iterator, std::size_t N, std::size_t Max, typename = void>
-  class bounded_recursive_iterator_impl :
-  public recursive_iterator_base< Iterator > {
+  class bounded_recursive_iterator_impl
+      : public recursive_iterator_base<Iterator> {
   public:
-    using super = recursive_iterator_base< Iterator >;
+    using super = recursive_iterator_base<Iterator>;
+
   public:
     using super::super;
     bounded_recursive_iterator_impl() = default;
     template <typename OIter>
     bounded_recursive_iterator_impl(in_place_t, OIter && iter)
         : super(std::forward<OIter>(iter)) {}
+
   protected:
     void next() { super::operator++(); }
-    void assign(super eat) { static_cast<super&>(*this) = eat; }
+    void assign(super eat) { static_cast<super &>(*this) = eat; }
   };
-  
+
   /**
    * @class bounded_recursive_iterator_impl
    *
@@ -113,11 +130,18 @@ namespace iterator { namespace detail {
    * @see recursive_iterator_layer
    */
   template <typename Iterator, std::size_t N, std::size_t Max>
-  class bounded_recursive_iterator_impl< Iterator, N, Max, typename std::enable_if<N < Max, typename void_t<value_iterator<Iterator>>::type>::type > :
-  public recursive_iterator_layer< Iterator , bounded_recursive_iterator_impl< value_iterator<Iterator>, N+1, Max > > {
+      class bounded_recursive_iterator_impl < Iterator,
+      N, Max,
+      typename std::enable_if<
+          N<Max, typename void_t<value_iterator<Iterator>>::type>::type>
+      : public recursive_iterator_layer<
+            Iterator, bounded_recursive_iterator_impl<value_iterator<Iterator>,
+                                                      N + 1, Max>> {
   public:
-    using next_layer = bounded_recursive_iterator_impl< value_iterator<Iterator>, N+1, Max >;
-    using super = recursive_iterator_layer< Iterator, next_layer >;
+    using next_layer =
+        bounded_recursive_iterator_impl<value_iterator<Iterator>, N + 1, Max>;
+    using super = recursive_iterator_layer<Iterator, next_layer>;
+
   public:
     /**
      * A special override of operator* that allows collections like
@@ -125,14 +149,16 @@ namespace iterator { namespace detail {
      * type of the map. Works only for nested collections with one associative
      * container at the bottom/Max level.
      */
-    auto operator*() const -> decltype(*(next_layer&)(*this)) { return next_layer::operator*(); }
+    auto operator*() const -> decltype(*(next_layer &)(*this)) {
+      return next_layer::operator*();
+    }
     using super::super;
     bounded_recursive_iterator_impl() = default;
     template <typename... Iterators>
-    bounded_recursive_iterator_impl(in_place_t, Iterators && ...iter)
+    bounded_recursive_iterator_impl(in_place_t, Iterators &&... iter)
         : super(in_place, std::forward<Iterators>(iter)...) {}
   };
-  
+
   /**
    * @class bounded_recursive_iterator_impl
    *
@@ -141,56 +167,62 @@ namespace iterator { namespace detail {
    * @see flatten_iterator_layer
    */
   template <typename Iterator, std::size_t N, std::size_t Max>
-  class bounded_recursive_iterator_impl< Iterator, N, Max, typename std::enable_if<N < Max, typename void_t<mapped_iterator<Iterator>>::type>::type > :
-  public flatten_iterator_layer< Iterator , bounded_recursive_iterator_impl< mapped_iterator<Iterator>, N+1, Max > > {
+      class bounded_recursive_iterator_impl < Iterator,
+      N, Max,
+      typename std::enable_if<
+          N<Max, typename void_t<mapped_iterator<Iterator>>::type>::type>
+      : public flatten_iterator_layer<
+            Iterator, bounded_recursive_iterator_impl<mapped_iterator<Iterator>,
+                                                      N + 1, Max>> {
   public:
-    using next_layer = bounded_recursive_iterator_impl< mapped_iterator<Iterator>, N+1, Max >;
-    using super = flatten_iterator_layer< Iterator, next_layer >;
+    using next_layer =
+        bounded_recursive_iterator_impl<mapped_iterator<Iterator>, N + 1, Max>;
+    using super = flatten_iterator_layer<Iterator, next_layer>;
+
   public:
     using super::super;
     bounded_recursive_iterator_impl() = default;
     template <typename... Iterators>
-    bounded_recursive_iterator_impl(in_place_t, Iterators && ...iter)
+    bounded_recursive_iterator_impl(in_place_t, Iterators &&... iter)
         : super(in_place, std::forward<Iterators>(iter)...) {}
   };
-} }
+}}
 
 namespace iterator { namespace detail {
-  template <std::size_t I, typename It, typename = void>
-  struct accessor;
-  
-  template <typename It>
-  struct accessor<0, end_aware_iterator<It>> {
+  template <std::size_t I, typename It, typename = void> struct accessor;
+
+  template <typename It> struct accessor<0, end_aware_iterator<It>> {
     using type = end_aware_iterator<It>;
   };
-  
+
   template <typename It, typename Rec>
   struct accessor<0, recursive_iterator_layer<It, Rec>> {
     using type = end_aware_iterator<It>;
   };
-    
+
   template <typename It, typename Rec>
   struct accessor<0, flatten_iterator_layer<It, Rec>> {
     using type = end_aware_iterator<It>;
   };
 
-  template <typename It>
-  struct accessor<0, It> {
+  template <typename It> struct accessor<0, It> {
     using type = typename accessor<0, typename It::super>::type;
   };
-  
+
   template <std::size_t I, typename It>
   struct accessor<I, It, typename std::enable_if<I != 0>::type> {
     using type = typename accessor<I, typename It::super>::type;
   };
-  
+
   template <std::size_t I, typename It, typename Rec>
-  struct accessor<I, recursive_iterator_layer<It, Rec>, typename std::enable_if<I != 0>::type> {
-    using type = typename accessor<I-1, Rec>::type;
+  struct accessor<I, recursive_iterator_layer<It, Rec>,
+                  typename std::enable_if<I != 0>::type> {
+    using type = typename accessor<I - 1, Rec>::type;
   };
-  
+
   template <std::size_t I, typename It, typename Rec>
-  struct accessor<I, flatten_iterator_layer<It, Rec>, typename std::enable_if<I != 0>::type> {
-    using type = typename accessor<I-1, Rec>::type;
+  struct accessor<I, flatten_iterator_layer<It, Rec>,
+                  typename std::enable_if<I != 0>::type> {
+    using type = typename accessor<I - 1, Rec>::type;
   };
-} }
+}}

+ 62 - 24
include/iterator/unkeyed_iterator.hpp

@@ -10,39 +10,77 @@
 #include <iterator>
 
 namespace iterator {
-  template <typename Iterator>
-  class unkeyed_iterator {
+  template <typename Iterator> class unkeyed_iterator {
   private:
     using impl_value_type = typename std::iterator_traits<Iterator>::value_type;
     using impl_reference = typename std::iterator_traits<Iterator>::reference;
-    static constexpr std::size_t const value_index = std::tuple_size<impl_value_type>::value - 1;
+    static constexpr std::size_t const value_index =
+        std::tuple_size<impl_value_type>::value - 1;
+
   public:
-    using value_type = typename std::remove_reference<decltype(std::get<value_index>(std::declval<impl_value_type>()))>::type;
-    using reference = decltype(std::get<value_index>(std::declval<impl_reference>()));
+    using value_type = typename std::remove_reference<decltype(
+        std::get<value_index>(std::declval<impl_value_type>()))>::type;
+    using reference =
+        decltype(std::get<value_index>(std::declval<impl_reference>()));
     using pointer = value_type *;
-    using difference_type = typename std::iterator_traits<Iterator>::difference_type;
-    using iterator_category = typename std::iterator_traits<Iterator>::iterator_category;
-    
+    using difference_type =
+        typename std::iterator_traits<Iterator>::difference_type;
+    using iterator_category =
+        typename std::iterator_traits<Iterator>::iterator_category;
+
     unkeyed_iterator() = default;
     unkeyed_iterator(Iterator it) : base(it) {}
-    
+
     reference operator*() const { return std::get<value_index>(*base); }
     pointer operator->() const { return std::addressof(operator*()); }
-    unkeyed_iterator & operator++() { ++base; return *this; }
-    unkeyed_iterator operator++(int) { unkeyed_iterator tmp{*this}; operator++(); return tmp; }
-    
-    unkeyed_iterator & operator--() { --base; return *this; }
-    unkeyed_iterator operator--(int) { unkeyed_iterator tmp{*this}; operator--(); return tmp; }
-    
-    unkeyed_iterator operator+(difference_type n) const { return unkeyed_iterator{*this} += n; }
-    unkeyed_iterator & operator+=(difference_type n) { base += n; return *this; }
-    unkeyed_iterator operator-(difference_type n) const { return unkeyed_iterator{*this} -= n; }
-    unkeyed_iterator & operator-=(difference_type n) { base -= n;return *this; }
-    
-    bool operator==(unkeyed_iterator const & other) const { return base == other.base; }
-    bool operator!=(unkeyed_iterator const & other) const { return base != other.base; }
-    bool operator< (unkeyed_iterator const & other) const { return base < other.base; }
-    bool operator<=(unkeyed_iterator const & other) const { return !(other < *this); }
+    unkeyed_iterator & operator++() {
+      ++base;
+      return *this;
+    }
+    unkeyed_iterator operator++(int) {
+      unkeyed_iterator tmp{*this};
+      operator++();
+      return tmp;
+    }
+
+    unkeyed_iterator & operator--() {
+      --base;
+      return *this;
+    }
+    unkeyed_iterator operator--(int) {
+      unkeyed_iterator tmp{*this};
+      operator--();
+      return tmp;
+    }
+
+    unkeyed_iterator operator+(difference_type n) const {
+      return unkeyed_iterator{*this} += n;
+    }
+    unkeyed_iterator & operator+=(difference_type n) {
+      base += n;
+      return *this;
+    }
+    unkeyed_iterator operator-(difference_type n) const {
+      return unkeyed_iterator{*this} -= n;
+    }
+    unkeyed_iterator & operator-=(difference_type n) {
+      base -= n;
+      return *this;
+    }
+
+    bool operator==(unkeyed_iterator const & other) const {
+      return base == other.base;
+    }
+    bool operator!=(unkeyed_iterator const & other) const {
+      return base != other.base;
+    }
+    bool operator<(unkeyed_iterator const & other) const {
+      return base < other.base;
+    }
+    bool operator<=(unkeyed_iterator const & other) const {
+      return !(other < *this);
+    }
+
   private:
     Iterator base;
   };

+ 4 - 3
test/end_aware_iterator_test.cxx

@@ -4,7 +4,8 @@
 
 #include <gmock/gmock.h>
 
-using end_aware_iterator = ::iterator::end_aware_iterator<std::vector<int>::iterator>;
+using end_aware_iterator =
+    ::iterator::end_aware_iterator<std::vector<int>::iterator>;
 
 TEST(EndAwareIteratorTest, BeginWrapperIsEqualToBegin) {
   std::vector<int> v{1, 2, 3, 4, 5};
@@ -19,10 +20,10 @@ TEST(EndAwareIteratorTest, MutableActionsArePassthrough) {
 
 TEST(EndAwareIteratorTest, CanTellYouThatItsReachedEnd) {
   std::vector<int> v{1, 2, 3, 4, 5};
-  end_aware_iterator it{v.end()-1, v.end()};
+  end_aware_iterator it{v.end() - 1, v.end()};
   EXPECT_FALSE(it.done());
   ++it;
-  EXPECT_THAT(it, end_aware_iterator(v.end(),v.end()));
+  EXPECT_THAT(it, end_aware_iterator(v.end(), v.end()));
   EXPECT_TRUE(it.done());
 }
 

+ 6 - 6
test/filter_iterator_test.cxx

@@ -3,8 +3,8 @@
 #include <gmock/gmock.h>
 
 TEST(FilterIteratorTest, CanPerformSkipsOnData) {
-  int data[] = { 1, 2, 3, 4, 5 };
-  auto pred = [](int i) { return i%2 == 0; };
+  int data[] = {1, 2, 3, 4, 5};
+  auto pred = [](int i) { return i % 2 == 0; };
   auto it = make_filter_iterator(pred, data);
   decltype(it) end = {};
   EXPECT_THAT(std::distance(it, end), 2);
@@ -13,16 +13,16 @@ TEST(FilterIteratorTest, CanPerformSkipsOnData) {
 }
 
 TEST(FilterIteratorTest, IfNonMatchThenStartIsEnd) {
-  int data[] = { 1, 3, 5 };
-  auto pred = [](int i) { return i%2 == 0; };
+  int data[] = {1, 3, 5};
+  auto pred = [](int i) { return i % 2 == 0; };
   auto it = make_filter_iterator(pred, data);
   decltype(it) end = {};
   EXPECT_THAT(it, end);
 }
 
 TEST(FilterIteratorTest, IncrementEndIsNoOp) {
-  int data[] = { 1, 2, 3, 4, 5 };
-  auto pred = [](int i) { return i%2 == 0; };
+  int data[] = {1, 2, 3, 4, 5};
+  auto pred = [](int i) { return i % 2 == 0; };
   auto it = make_filter_iterator(pred, data);
   decltype(it) end = {};
   ++++it;

+ 2 - 1
test/indexed_iterator_test.cxx

@@ -4,7 +4,8 @@
 
 #include <gmock/gmock.h>
 
-using idx_iterator = iterator::indexed_iterator<std::vector<int>::const_iterator>;
+using idx_iterator =
+    iterator::indexed_iterator<std::vector<int>::const_iterator>;
 
 TEST(IndexedIteratorTest, TreatsVectorIteratorAsMapIdxToValue) {
   std::vector<int> const vec{5, 3, 2, 8, 9, 11, 2, 4};

+ 9 - 8
test/join_iterator_test.cxx

@@ -4,28 +4,29 @@
 
 #include <gmock/gmock.h>
 
-using join_iterator = iterator::joining_iterator<std::vector<std::vector<int>>::iterator>;
+using join_iterator =
+    iterator::joining_iterator<std::vector<std::vector<int>>::iterator>;
 
 TEST(JoinIteratorTest, FirstDereferencedElemIsTheFirstInTheChain) {
-  std::vector<std::vector<int>> mv{{1,2,3},{4,5,6}};
+  std::vector<std::vector<int>> mv{{1, 2, 3}, {4, 5, 6}};
   EXPECT_THAT(*join_iterator(make_end_aware_iterator(mv)), mv[0][0]);
 }
 
 TEST(JoinIteratorTest, EmptyConstructorEqualsEnd) {
-  std::vector<std::vector<int>> mv{{1,2,3},{4,5,6}};
-  join_iterator it({ mv.end(), mv.end() }, { mv.back().end(), mv.back().end() } );
+  std::vector<std::vector<int>> mv{{1, 2, 3}, {4, 5, 6}};
+  join_iterator it({mv.end(), mv.end()}, {mv.back().end(), mv.back().end()});
   EXPECT_THAT(it, join_iterator());
 }
 
 TEST(JoinIteratorTest, MovesFromListToListWhenReachingEnd) {
-  std::vector<std::vector<int>> mv{{1,2,3},{4,5,6}};
-  join_iterator it(make_end_aware_iterator(mv), { mv[0].end(), mv[0].end() });
+  std::vector<std::vector<int>> mv{{1, 2, 3}, {4, 5, 6}};
+  join_iterator it(make_end_aware_iterator(mv), {mv[0].end(), mv[0].end()});
   EXPECT_THAT(*++it, mv[1][0]);
 }
 
 TEST(JoinIteratorTest, IncrementEndIsNoOp) {
-  std::vector<std::vector<int>> mv{{1,2,3},{4,5,6}};
-  join_iterator it( { mv.end(), mv.end() }, { mv.back().end(), mv.back().end() });
+  std::vector<std::vector<int>> mv{{1, 2, 3}, {4, 5, 6}};
+  join_iterator it({mv.end(), mv.end()}, {mv.back().end(), mv.back().end()});
   join_iterator const cp = it;
   ++it;
   EXPECT_THAT(it, cp);

+ 17 - 15
test/recursive_iterator_accessors_test.cxx

@@ -7,22 +7,27 @@
 
 TEST(RecursiveIteratorTest, CanStdGetToAllLayersOfInternalIteration) {
   std::map<int, std::vector<std::map<int, int>>> obj{
-    {1, {{{1, 1}}, {{2, 2}}}}, // 2 1-element maps
-    {2, {{{3, 3}, {4, 4}}}} // 1 2-element map
+      {1, {{{1, 1}}, {{2, 2}}}}, // 2 1-element maps
+      {2, {{{3, 3}, {4, 4}}}}    // 1 2-element map
   };
   auto rit = make_recursive_iterator(obj);
-  EXPECT_TRUE((testing::StaticAssertTypeEq<decltype(std::get<0>(rit)),
-               iterator::end_aware_iterator<std::map<int, std::vector<std::map<int, int>>>::iterator>>()));
-  EXPECT_TRUE((testing::StaticAssertTypeEq<decltype(std::get<1>(rit)),
-               iterator::end_aware_iterator<std::vector<std::map<int, int>>::iterator>>()));
-  EXPECT_TRUE((testing::StaticAssertTypeEq<decltype(std::get<2>(rit)),
+  EXPECT_TRUE(
+      (testing::StaticAssertTypeEq<
+          decltype(std::get<0>(rit)),
+          iterator::end_aware_iterator<
+              std::map<int, std::vector<std::map<int, int>>>::iterator>>()));
+  EXPECT_TRUE(
+      (testing::StaticAssertTypeEq<decltype(std::get<1>(rit)),
+                                   iterator::end_aware_iterator<std::vector<
+                                       std::map<int, int>>::iterator>>()));
+  EXPECT_TRUE((testing::StaticAssertTypeEq<
+               decltype(std::get<2>(rit)),
                iterator::end_aware_iterator<std::map<int, int>::iterator>>()));
 }
 
 TEST(RecursiveIteratorTest, CanConstructInPlaceFromIterators) {
   std::map<int, std::vector<std::map<int, int>>> const obj{
-    {1, {{{1, 1}}, {{2, 2}}}}, {2, {{{3, 3}, {4, 4}}}}
-  };
+      {1, {{{1, 1}}, {{2, 2}}}}, {2, {{{3, 3}, {4, 4}}}}};
   auto const it = make_end_aware_iterator(obj.begin(), obj.end());
   auto const it_1 = ++make_end_aware_iterator(it->second);
   auto const it_2 = make_end_aware_iterator(*it_1);
@@ -33,15 +38,12 @@ TEST(RecursiveIteratorTest, CanConstructInPlaceFromIterators) {
 
 TEST(RecursiveIteratorTest, InternalIteratorsFromStdGetMatchCtorArgs) {
   std::map<int, std::vector<std::map<int, int>>> const obj{
-    {1, {{{1, 1}}, {{2, 2}}}}, {2, {{{3, 3}, {4, 4}}}}
-  };
+      {1, {{{1, 1}}, {{2, 2}}}}, {2, {{{3, 3}, {4, 4}}}}};
   auto const it = make_end_aware_iterator(obj.begin(), obj.end());
   auto const it_1 = ++make_end_aware_iterator(it->second);
   auto const it_2 = make_end_aware_iterator(*it_1);
-  iterator::recursive_iterator<decltype(obj.cbegin())> rit{
-    iterator::in_place,
-    it, it_1, it_2
-  };
+  iterator::recursive_iterator<decltype(obj.cbegin())> rit{iterator::in_place,
+                                                           it, it_1, it_2};
   EXPECT_THAT(std::get<0>(rit), it);
   EXPECT_THAT(std::get<1>(rit), it_1);
   EXPECT_THAT(std::get<2>(rit), it_2);

+ 15 - 27
test/recursive_iterator_map_test.cxx

@@ -9,7 +9,7 @@
 TEST(RecursiveIteratorSingleMapTest, IterDistanceIsContainerSize) {
   std::map<int, int> const map{{1, 1}, {2, 2}, {3, 3}};
   auto rit = make_recursive_iterator(map);
-  decltype(rit) end{ };
+  decltype(rit) end{};
   EXPECT_THAT(std::distance(rit, end), map.size());
 }
 
@@ -30,58 +30,46 @@ TEST(RecursiveIteratorSingleMapTest, CanMutatePointedToData) {
 }
 
 TEST(RecursiveIteratorMapMapTest, IterDistanceIsSumOfInnerContainerSizes) {
-  std::map<int, std::map<int, int>> const map{
-    {1, {{1, 1}}},
-    {2, {{2, 2}, {3, 3}}}
-  };
+  std::map<int, std::map<int, int>> const map{{1, {{1, 1}}},
+                                              {2, {{2, 2}, {3, 3}}}};
   auto rit = make_recursive_iterator(map);
-  decltype(rit) end{ };
+  decltype(rit) end{};
   // TODO: Actually perform the summation?
   EXPECT_THAT(std::distance(rit, end), 3);
 }
 
 TEST(RecursiveIteratorMapMapTest, ElementsAreUnwrappedAsATuple) {
-  std::map<int, std::map<int, int>> const map{
-    {1, {{1, 1}}},
-    {2, {{2, 2}, {3, 3}}}
-  };
+  std::map<int, std::map<int, int>> const map{{1, {{1, 1}}},
+                                              {2, {{2, 2}, {3, 3}}}};
   std::vector<std::tuple<int, int, int>> const expected{
-    {1, 1, 1}, {2, 2, 2}, {2, 3, 3}};
+      {1, 1, 1}, {2, 2, 2}, {2, 3, 3}};
   auto rit = make_recursive_iterator(map);
   // TODO: Collapse into a container instead
-  for (auto it = expected.begin(), end = expected.end(); it != end; ++it, ++rit) {
+  for (auto it = expected.begin(), end = expected.end(); it != end;
+       ++it, ++rit) {
     EXPECT_THAT(std::tuple_cat(*it), *rit);
   }
 }
 
 TEST(RecursiveIteratorMapMapTest, CanMutatePointedToData) {
-  std::map<int, std::map<int, int>> map{
-    {1, {{1, 1}}},
-    {2, {{2, 2}, {3, 3}}}
-  };
+  std::map<int, std::map<int, int>> map{{1, {{1, 1}}}, {2, {{2, 2}, {3, 3}}}};
   auto rit = make_recursive_iterator(map);
   std::get<2>(*rit) = 4;
   EXPECT_THAT(map[1][1], 4);
 }
 
 TEST(BoundRecursiveIteratorMapMapTest, IterDistanceSumOnNLayersSize) {
-  std::map<int, std::map<int, int>> map{
-    {1, {{1, 1}}},
-    {2, {{2, 2}, {3, 3}}}
-  };
+  std::map<int, std::map<int, int>> map{{1, {{1, 1}}}, {2, {{2, 2}, {3, 3}}}};
   auto rit = make_recursive_iterator<1>(map);
-  decltype(rit) end{ };
-  
+  decltype(rit) end{};
+
   EXPECT_THAT(std::distance(rit, end), map.size());
 }
 
 TEST(BoundRecursiveIteratorMapMapTest, ElementsAreUnwrappedAsATuple) {
-  std::map<int, std::map<int, int>> map{
-    {1, {{1, 1}}},
-    {2, {{2, 2}, {3, 3}}}
-  };
+  std::map<int, std::map<int, int>> map{{1, {{1, 1}}}, {2, {{2, 2}, {3, 3}}}};
   auto rit = make_recursive_iterator<1>(map);
-  
+
   // TODO: Collapse into a container instead
   for (auto it = map.begin(), end = map.end(); it != end; ++it, ++rit) {
     EXPECT_THAT(*it, *rit);

+ 29 - 67
test/recursive_iterator_mixed_container_test.cxx

@@ -6,70 +6,57 @@
 #include <gmock/gmock.h>
 
 TEST(RecursiveIteratorMapVectorTest, IterDistanceIsSumOfInnerContainerSizes) {
-  std::map<int, std::vector<int>> const obj{
-    {1, {1, 2}},
-    {2, {3, 4, 5}}
-  };
+  std::map<int, std::vector<int>> const obj{{1, {1, 2}}, {2, {3, 4, 5}}};
   auto rit = make_recursive_iterator(obj);
-  decltype(rit) end{ };
+  decltype(rit) end{};
   // TODO: Actually perform the summation?
   EXPECT_THAT(std::distance(rit, end), 5);
 }
 
 TEST(RecursiveIteratorMapVectorTest, ElementsAreUnwrappedAsATuple) {
-  std::map<int, std::vector<int>> const obj{
-    {1, {1, 2}},
-    {2, {3, 4, 5}}
-  };
+  std::map<int, std::vector<int>> const obj{{1, {1, 2}}, {2, {3, 4, 5}}};
   std::vector<std::tuple<int, int>> const expected{
-    {1, 1}, {1, 2}, {2, 3}, {2, 4}, {2, 5}};
+      {1, 1}, {1, 2}, {2, 3}, {2, 4}, {2, 5}};
   // TODO: Collapse into a container instead
   auto rit = make_recursive_iterator(obj);
-  for (auto it = expected.begin(), end = expected.end(); it != end; ++it, ++rit) {
+  for (auto it = expected.begin(), end = expected.end(); it != end;
+       ++it, ++rit) {
     EXPECT_THAT(*it, *rit);
   }
 }
 
 TEST(RecursiveIteratorMapVectorTest, CanMutatePointedToData) {
-  std::map<int, std::vector<int>> obj{
-    {1, {1, 2}},
-    {2, {3, 4, 5}}
-  };
+  std::map<int, std::vector<int>> obj{{1, {1, 2}}, {2, {3, 4, 5}}};
   auto rit = make_recursive_iterator(obj);
   std::get<1>(*rit) = 6;
   EXPECT_THAT(obj[1][0], 6);
 }
 
 TEST(RecursiveIteratorVectorMapTest, IterDistanceIsSumOfInnerContainerSizes) {
-  std::vector<std::map<int, int>> const obj{
-    {{1, 1}, {2, 2}},
-    {{3, 3}, {4, 4}, {5, 5}}
-  };
+  std::vector<std::map<int, int>> const obj{{{1, 1}, {2, 2}},
+                                            {{3, 3}, {4, 4}, {5, 5}}};
   auto rit = make_recursive_iterator(obj);
-  decltype(rit) end{ };
+  decltype(rit) end{};
   // TODO: Actually perform the summation?
   EXPECT_THAT(std::distance(rit, end), 5);
 }
 
 TEST(RecursiveIteratorVectorMapTest, ElementsAreUnwrappedAsATuple) {
-  std::vector<std::map<int, int>> const obj{
-    {{1, 1}, {2, 2}},
-    {{3, 3}, {4, 4}, {5, 5}}
-  };
+  std::vector<std::map<int, int>> const obj{{{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}};
+      {1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}};
   auto rit = make_recursive_iterator(obj);
   // TODO: Collapse into a container instead
-  for (auto it = expected.begin(), end = expected.end(); it != end; ++it, ++rit) {
+  for (auto it = expected.begin(), end = expected.end(); it != end;
+       ++it, ++rit) {
     EXPECT_THAT(*it, *rit);
   }
 }
 
 TEST(RecursiveIteratorVectorMapTest, CanMutatePointedToData) {
-  std::vector<std::map<int, int>> obj{
-    {{1, 1}, {2, 2}},
-    {{3, 3}, {4, 4}, {5, 5}}
-  };
+  std::vector<std::map<int, int>> obj{{{1, 1}, {2, 2}},
+                                      {{3, 3}, {4, 4}, {5, 5}}};
   auto rit = make_recursive_iterator(obj);
   std::get<1>(*rit) = 6;
   EXPECT_THAT(obj[0][1], 6);
@@ -77,26 +64,21 @@ TEST(RecursiveIteratorVectorMapTest, CanMutatePointedToData) {
 
 TEST(RecursiveIteratorMapVecMapTest, IterDistanceIsSumOfInnerContainerSizes) {
   std::map<int, std::vector<std::map<int, int>>> const obj{
-    {1, {
-      {{1, 1}, {2, 2}}
-    }}
-  };
+      {1, {{{1, 1}, {2, 2}}}}};
   std::vector<std::tuple<int, int, int>> const expected{{1, 1, 1}, {1, 2, 2}};
   auto rit = make_recursive_iterator(obj);
-  decltype(rit) end{ };
+  decltype(rit) end{};
   EXPECT_THAT(std::distance(rit, end), expected.size());
 }
 
 TEST(RecursiveIteratorMapVecMapTest, ElementsAreUnwrappedAsATuple) {
   std::map<int, std::vector<std::map<int, int>>> const obj{
-    {1, {
-      {{1, 1}, {2, 2}}
-    }}
-  };
+      {1, {{{1, 1}, {2, 2}}}}};
   std::vector<std::tuple<int, int, int>> const expected{{1, 1, 1}, {1, 2, 2}};
   auto rit = make_recursive_iterator(obj);
   // TODO: Collapse into a container instead
-  for (auto it = expected.begin(), end = expected.end(); it != end; ++it, ++rit) {
+  for (auto it = expected.begin(), end = expected.end(); it != end;
+       ++it, ++rit) {
     EXPECT_THAT(*it, *rit);
   }
 }
@@ -110,49 +92,29 @@ TEST(RecursiveIteratorMapVecMapTest, CanMutatePointedToData) {
 
 TEST(RecursiveIteratorVecMapVecTest, IterDistanceIsSumOfInnerContainerSizes) {
   std::vector<std::map<int, std::vector<int>>> const obj{
-    {
-      {1, {1, 2}},
-      {2, {3, 4, 5}}
-    },
-    {
-      {1, {3, 4}}
-    }
-  };
+      {{1, {1, 2}}, {2, {3, 4, 5}}}, {{1, {3, 4}}}};
   auto rit = make_recursive_iterator(obj);
-  decltype(rit) end{ };
+  decltype(rit) end{};
   // TODO: Actually perform the summation?
   EXPECT_THAT(std::distance(rit, end), 7);
 }
 
 TEST(RecursiveIteratorVecMapVecTest, ElementsAreUnwrappedAsATuple) {
   std::vector<std::map<int, std::vector<int>>> const obj{
-    {
-      {1, {1, 2}},
-      {2, {3, 4, 5}}
-    },
-    {
-      {1, {3, 4}}
-    }
-  };
+      {{1, {1, 2}}, {2, {3, 4, 5}}}, {{1, {3, 4}}}};
   std::vector<std::tuple<int, int>> const expected{
-    {1, 1}, {1, 2}, {2, 3}, {2, 4}, {2, 5}, {1, 3}, {1, 4}};
+      {1, 1}, {1, 2}, {2, 3}, {2, 4}, {2, 5}, {1, 3}, {1, 4}};
   auto rit = make_recursive_iterator(obj);
   // TODO: Collapse into a container instead
-  for (auto it = expected.begin(), end = expected.end(); it != end; ++it, ++rit) {
+  for (auto it = expected.begin(), end = expected.end(); it != end;
+       ++it, ++rit) {
     EXPECT_THAT(*it, *rit);
   }
 }
 
 TEST(RecursiveIteratorVecMapVecTest, CanMutatePointedToData) {
   std::vector<std::map<int, std::vector<int>>> obj{
-    {
-      {1, {1, 2}},
-      {2, {3, 4, 5}}
-    },
-    {
-      {1, {3, 4}}
-    }
-  };
+      {{1, {1, 2}}, {2, {3, 4, 5}}}, {{1, {3, 4}}}};
   auto rit = make_recursive_iterator(obj);
   std::get<1>(*rit) = 6;
   EXPECT_THAT(obj[0][1][0], 6);

+ 10 - 8
test/recursive_iterator_vector_test.cxx

@@ -7,14 +7,14 @@
 TEST(RecursiveIteratorSingleVectorTest, IterDistanceIsContainerSize) {
   std::vector<int> const vec{1, 2, 3, 4, 5};
   auto rit = make_recursive_iterator(vec);
-  decltype(rit) end{ };
+  decltype(rit) end{};
   EXPECT_THAT(std::distance(rit, end), vec.size());
 }
 
 TEST(RecursiveIteratorSingleVectorTest, ElementsAreUnwrappedAsATuple) {
   std::vector<int> const vec{1, 2, 3, 4, 5};
   auto rit = make_recursive_iterator(vec);
-  
+
   // TODO: Collapse into a container instead
   for (auto it = vec.begin(), end = vec.end(); it != end; ++it, ++rit) {
     EXPECT_THAT(*it, *rit);
@@ -28,10 +28,11 @@ TEST(RecursiveIteratorSingleVectorTest, CanMutatePointedToData) {
   EXPECT_THAT(vec[0], 6);
 }
 
-TEST(RecursiveIteratorVectorVectorTest, IterDistanceIsSumOfInnerContainerSizes) {
+TEST(RecursiveIteratorVectorVectorTest,
+     IterDistanceIsSumOfInnerContainerSizes) {
   std::vector<std::vector<int>> const vec{{1, 2}, {3, 4, 5}};
   auto rit = make_recursive_iterator(vec);
-  decltype(rit) end{ };
+  decltype(rit) end{};
 
   // TODO: Actually perform the summation?
   EXPECT_THAT(std::distance(rit, end), 5);
@@ -41,9 +42,10 @@ TEST(RecursiveIteratorVectorVectorTest, ElementsAreUnwrappedAsATuple) {
   std::vector<std::vector<int>> const vec{{1, 2}, {3, 4, 5}};
   std::vector<int> const expected{1, 2, 3, 4, 5};
   auto rit = make_recursive_iterator(vec);
-  
+
   // TODO: Collapse into a container instead
-  for (auto it = expected.begin(), end = expected.end(); it != end; ++it, ++rit) {
+  for (auto it = expected.begin(), end = expected.end(); it != end;
+       ++it, ++rit) {
     EXPECT_THAT(*it, *rit);
   }
 }
@@ -58,8 +60,8 @@ TEST(RecursiveIteratorVectorVectorTest, CanMutatePointedToData) {
 TEST(BoundedRecursiveIteratorVectorVectorTest, IterDistanceSumOnNLayersSize) {
   std::vector<std::vector<int>> const vec{{1, 2}, {3, 4, 5}};
   auto rit = make_recursive_iterator<1>(vec);
-  decltype(rit) end{ };
-  
+  decltype(rit) end{};
+
   EXPECT_THAT(std::distance(rit, end), vec.size());
 }
 

+ 2 - 3
test/unkeyed_iterator_test.cxx

@@ -10,9 +10,8 @@ TEST(UnkeyedIteratorTest, IteratorOnlyReturnsValues) {
   std::vector<int> const expected{2, 3};
   iterator::unkeyed_iterator<std::map<int, int>::iterator>{map.begin()};
   std::vector<int> const result{
-    iterator::unkeyed_iterator<std::map<int, int>::iterator>{map.begin()},
-    iterator::unkeyed_iterator<std::map<int, int>::iterator>{map.end()}
-  };
+      iterator::unkeyed_iterator<std::map<int, int>::iterator>{map.begin()},
+      iterator::unkeyed_iterator<std::map<int, int>::iterator>{map.end()}};
   EXPECT_THAT(result, expected);
 }