Move folly/BitIterator.h to folly/container/
[folly.git] / folly / gen / Base.h
index 625cd0609d2a58d49895bac3c4c5f51ff531d6e6..dd74a092a68046adc2e889839034ed82d0cab914 100644 (file)
@@ -84,7 +84,7 @@ namespace folly {
 namespace gen {
 
 class Less {
-public:
+ public:
   template <class First, class Second>
   auto operator()(const First& first, const Second& second) const ->
   decltype(first < second) {
@@ -93,7 +93,7 @@ public:
 };
 
 class Greater {
-public:
+ public:
   template <class First, class Second>
   auto operator()(const First& first, const Second& second) const ->
   decltype(first > second) {
@@ -103,7 +103,7 @@ public:
 
 template <int n>
 class Get {
-public:
+ public:
   template <class Value>
   auto operator()(Value&& value) const ->
   decltype(std::get<n>(std::forward<Value>(value))) {
@@ -188,7 +188,7 @@ class Field {
 };
 
 class Move {
-public:
+ public:
   template <class Value>
   auto operator()(Value&& value) const ->
   decltype(std::move(std::forward<Value>(value))) {
@@ -330,6 +330,9 @@ class Sample;
 
 class Skip;
 
+template <class Visitor>
+class Visit;
+
 template <class Selector, class Comparer = Less>
 class Order;
 
@@ -354,6 +357,8 @@ class Cycle;
 
 class Batch;
 
+class Window;
+
 class Dereference;
 
 class Indirect;
@@ -402,7 +407,7 @@ class UnwrapOr;
 
 class Unwrap;
 
-}
+} // namespace detail
 
 /**
  * Polymorphic wrapper
@@ -498,9 +503,8 @@ Yield generator(Source&& source) {
  *
  *  auto gen = GENERATOR(int) { yield(1); yield(2); };
  */
-#define GENERATOR(TYPE)                            \
-  ::folly::gen::detail::GeneratorBuilder<TYPE>() + \
-   [=](const std::function<void(TYPE)>& yield)
+#define GENERATOR(TYPE) \
+  ::folly::gen::detail::GeneratorBuilder<TYPE>() + [=](auto&& yield)
 
 /*
  * empty() - for producing empty sequences.
@@ -634,6 +638,11 @@ Filter filter(Predicate pred = Predicate()) {
   return Filter(std::move(pred));
 }
 
+template <class Visitor = Ignore, class Visit = detail::Visit<Visitor>>
+Visit visit(Visitor visitor = Visitor()) {
+  return Visit(std::move(visitor));
+}
+
 template <class Predicate, class Until = detail::Until<Predicate>>
 Until until(Predicate pred = Predicate()) {
   return Until(std::move(pred));
@@ -742,7 +751,6 @@ Composed any(Predicate pred = Predicate()) {
  *
  *   from(source) | all(pred) == from(source) | filter(negate(pred)) | isEmpty
  */
-
 template <
     class Predicate = Identity,
     class Filter = detail::Filter<Negate<Predicate>>,
@@ -814,7 +822,8 @@ template <
 UnwrapOr unwrapOr(Fallback&& fallback) {
   return UnwrapOr(std::forward<Fallback>(fallback));
 }
-} // gen
-} // folly
+
+} // namespace gen
+} // namespace folly
 
 #include <folly/gen/Base-inl.h>