浏览代码

Re-run clang-format

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

+ 1 - 1
include/stream/streams.hpp

@@ -2,8 +2,8 @@
 
 #include "streams/forward.hpp"
 
-#include "streams/streams.hpp"
 #include "streams/make_stream.hpp"
+#include "streams/streams.hpp"
 
 #include "streams/source.hpp"
 

+ 1 - 1
include/stream/streams/filter.hpp

@@ -21,7 +21,7 @@ namespace stream { namespace detail {
     bool operator==(filter_iterator const & rhs) const {
       return impl_ == rhs.impl_;
     }
-    
+
   private:
     void advance() {
       while (impl_ != end_ && !pred_(mem_ = *impl_)) {

+ 6 - 3
include/stream/streams/join.hpp

@@ -1,9 +1,9 @@
 #pragma once
 
-#include <iterator>
 #include "self_iterating_contianer.hpp"
+#include <iterator>
 
-namespace stream { namespace detail {  
+namespace stream { namespace detail {
   template <typename C> class join_iterator {
   public:
     using reference = typename C::const_iterator::reference;
@@ -25,7 +25,10 @@ namespace stream { namespace detail {
       return *this;
     }
 
-    bool operator==(join_iterator const & rhs) const { return start_ == rhs.start_; }
+    bool operator==(join_iterator const & rhs) const {
+      return start_ == rhs.start_;
+    }
+
   private:
     void advance() {
       while (!current_ && start_ != finish_) {

+ 7 - 5
include/stream/streams/make_stream.hpp

@@ -4,8 +4,9 @@
 
 namespace stream {
   /**
-   * Construct a stream out of the given container. If C && is an rvalue reference, the returned object
-   * will take ownership of cont. Otherwise, we capture cont by reference to maximise performance.
+   * Construct a stream out of the given container. If C && is an rvalue
+   * reference, the returned object will take ownership of cont. Otherwise, we
+   * capture cont by reference to maximise performance.
    */
   template <typename C>
   auto make_stream(C && cont) -> detail::stream_base<decltype(*cont.begin())> {
@@ -21,7 +22,8 @@ namespace stream {
 
   /**
    * Construct a stream from input iterators representing the start and end
-   * Requirements: It must be an iterator type that provides the trait 'reference'
+   * Requirements: It must be an iterator type that provides the trait
+   * 'reference'
    */
   template <typename It>
   detail::stream_base<typename It::reference> make_stream(It begin, It end) {
@@ -43,8 +45,8 @@ namespace stream {
   }
 
   /**
-   * Construct a stream given certain start and end bounds, as well as an increment amount.
-   * e.g. stream::make_range_stream(0, 10, 2)
+   * Construct a stream given certain start and end bounds, as well as an
+   * increment amount. e.g. stream::make_range_stream(0, 10, 2)
    */
   template <typename T>
   detail::stream_base<T &> make_range_stream(T start, T const & end,

+ 4 - 1
include/stream/streams/map.hpp

@@ -11,7 +11,10 @@ namespace stream { namespace detail {
       ++impl_;
       return *this;
     }
-    bool operator==(map_iterator const & rhs) const { return impl_ == rhs.impl_; }
+    bool operator==(map_iterator const & rhs) const {
+      return impl_ == rhs.impl_;
+    }
+
   private:
     std::function<R(T const &)> fun_;
     iterator<T> impl_;

+ 55 - 54
include/stream/streams/self_iterating_contianer.hpp

@@ -1,58 +1,59 @@
 #pragma once
 
 namespace stream { namespace detail {
-template <typename C, typename It = typename C::const_iterator>
-class self_iterating_container {
-private:
-  std::ptrdiff_t offset{0};
-  C container;
-  It current;
-  It end;
-
-public:
-  self_iterating_container() = default;
-  self_iterating_container(C const & container)
-      : container(container), current(container.cbegin()),
-        end(container.cend()) {}
-  
-  self_iterating_container(C && container)
-      : container(std::move(container)), current(container.cbegin()),
-        end(container.cend()) {}
-  
-  self_iterating_container(self_iterating_container const & other) {
-    *this = other;
-  }
-  
-  self_iterating_container(self_iterating_container && other) {
-    *this = std::move(other);
-  }
-
-  self_iterating_container & operator=(self_iterating_container const & other) {
-    offset = other.offset;
-    container = other.container;
-    setup();
-    return *this;
-  }
-  
-  self_iterating_container & operator=(self_iterating_container && other) {
-    offset = other.offset;
-    container = std::move(other.container);
-    setup();
-    return *this;
-  }
-  
-  void operator++() {
-    ++offset;
-    ++current;
-  }
-  auto& operator*() const { return *current; }
-  operator bool() const { return current != end; }
-  
-private:
-  void setup() {
-    current = container.cbegin();
-    end = container.cend();
-    std::advance(current, offset);
-  }
-};
+  template <typename C, typename It = typename C::const_iterator>
+  class self_iterating_container {
+  private:
+    std::ptrdiff_t offset{0};
+    C container;
+    It current;
+    It end;
+
+  public:
+    self_iterating_container() = default;
+    self_iterating_container(C const & container)
+        : container(container), current(container.cbegin()),
+          end(container.cend()) {}
+
+    self_iterating_container(C && container)
+        : container(std::move(container)), current(container.cbegin()),
+          end(container.cend()) {}
+
+    self_iterating_container(self_iterating_container const & other) {
+      *this = other;
+    }
+
+    self_iterating_container(self_iterating_container && other) {
+      *this = std::move(other);
+    }
+
+    self_iterating_container &
+    operator=(self_iterating_container const & other) {
+      offset = other.offset;
+      container = other.container;
+      setup();
+      return *this;
+    }
+
+    self_iterating_container & operator=(self_iterating_container && other) {
+      offset = other.offset;
+      container = std::move(other.container);
+      setup();
+      return *this;
+    }
+
+    void operator++() {
+      ++offset;
+      ++current;
+    }
+    auto & operator*() const { return *current; }
+    operator bool() const { return current != end; }
+
+  private:
+    void setup() {
+      current = container.cbegin();
+      end = container.cend();
+      std::advance(current, offset);
+    }
+  };
 }}

+ 1 - 1
include/stream/streams/source.hpp

@@ -14,7 +14,7 @@ namespace stream { namespace detail {
     bool operator==(source_iterator const & rhs) const {
       return impl_ == rhs.impl_;
     }
-    
+
   private:
     Iter impl_;
   };