Apply clang-format to folly/gen/ (template decls)
[folly.git] / folly / gen / Core-inl.h
index bd66827e791a626b92df7a94848851bc09fcbfd0..1097d13cc9b1213fbc8cee91b20316b564db696b 100644 (file)
@@ -37,24 +37,23 @@ namespace gen {
  * Usage:
  *   IsCompatibleSignature<FunctorType, bool(int, float)>::value
  */
-template<class Candidate, class Expected>
+template <class Candidate, class Expected>
 class IsCompatibleSignature {
   static constexpr bool value = false;
 };
 
-template<class Candidate,
-         class ExpectedReturn,
-         class... ArgTypes>
+template <class Candidate, class ExpectedReturn, class... ArgTypes>
 class IsCompatibleSignature<Candidate, ExpectedReturn(ArgTypes...)> {
-  template<class F,
-           class ActualReturn =
-             decltype(std::declval<F>()(std::declval<ArgTypes>()...)),
-           bool good = std::is_same<ExpectedReturn, ActualReturn>::value>
+  template <
+      class F,
+      class ActualReturn =
+          decltype(std::declval<F>()(std::declval<ArgTypes>()...)),
+      bool good = std::is_same<ExpectedReturn, ActualReturn>::value>
   static constexpr bool testArgs(int*) {
     return good;
   }
 
-  template<class F>
+  template <class F>
   static constexpr bool testArgs(...) {
     return false;
   }
@@ -66,7 +65,7 @@ public:
  * FBounded - Helper type for the curiously recurring template pattern, used
  * heavily here to enable inlining and obviate virtual functions
  */
-template<class Self>
+template <class Self>
 struct FBounded {
   const Self& self() const {
     return *static_cast<const Self*>(this);
@@ -82,16 +81,14 @@ struct FBounded {
  * generator. All operators implement a method compose(), which takes a
  * generator and produces an output generator.
  */
-template<class Self>
+template <class Self>
 class Operator : public FBounded<Self> {
  public:
   /**
    * compose() - Must be implemented by child class to compose a new Generator
    * out of a given generator. This function left intentionally unimplemented.
    */
-  template<class Source,
-           class Value,
-           class ResultGen = void>
+  template <class Source, class Value, class ResultGen = void>
   ResultGen compose(const GenImpl<Value, Source>& source) const;
 
  protected:
@@ -106,33 +103,37 @@ class Operator : public FBounded<Self> {
  * operator|() - For composing two operators without binding it to a
  * particular generator.
  */
-template<class Left,
-         class Right,
-         class Composed = detail::Composed<Left, Right>>
+template <
+    class Left,
+    class Right,
+    class Composed = detail::Composed<Left, Right>>
 Composed operator|(const Operator<Left>& left,
                    const Operator<Right>& right) {
   return Composed(left.self(), right.self());
 }
 
-template<class Left,
-         class Right,
-         class Composed = detail::Composed<Left, Right>>
+template <
+    class Left,
+    class Right,
+    class Composed = detail::Composed<Left, Right>>
 Composed operator|(const Operator<Left>& left,
                    Operator<Right>&& right) {
   return Composed(left.self(), std::move(right.self()));
 }
 
-template<class Left,
-         class Right,
-         class Composed = detail::Composed<Left, Right>>
+template <
+    class Left,
+    class Right,
+    class Composed = detail::Composed<Left, Right>>
 Composed operator|(Operator<Left>&& left,
                    const Operator<Right>& right) {
   return Composed(std::move(left.self()), right.self());
 }
 
-template<class Left,
-         class Right,
-         class Composed = detail::Composed<Left, Right>>
+template <
+    class Left,
+    class Right,
+    class Composed = detail::Composed<Left, Right>>
 Composed operator|(Operator<Left>&& left,
                    Operator<Right>&& right) {
   return Composed(std::move(left.self()), std::move(right.self()));
@@ -144,8 +145,7 @@ Composed operator|(Operator<Left>&& left,
  * implement apply(). foreach() may also be implemented to special case the
  * condition where the entire sequence is consumed.
  */
-template<class Value,
-         class Self>
+template <class Value, class Self>
 class GenImpl : public FBounded<Self> {
  protected:
   // To prevent slicing
@@ -166,13 +166,13 @@ class GenImpl : public FBounded<Self> {
    * the handler returning false), as 'Chain' uses the return value of apply to
    * determine if it should process the second object in its chain.
    */
-  template<class Handler>
+  template <class Handler>
   bool apply(Handler&& handler) const;
 
   /**
    * foreach() - Send all values produced by this generator to given lambda.
    */
-  template<class Body>
+  template <class Body>
   void foreach(Body&& body) const {
     this->self().apply([&](Value value) -> bool {
         static_assert(!infinite, "Cannot call foreach on infinite GenImpl");
@@ -194,11 +194,12 @@ class GenImpl : public FBounded<Self> {
   static constexpr bool infinite = false;
 };
 
-template<class LeftValue,
-         class Left,
-         class RightValue,
-         class Right,
-         class Chain = detail::Chain<LeftValue, Left, Right>>
+template <
+    class LeftValue,
+    class Left,
+    class RightValue,
+    class Right,
+    class Chain = detail::Chain<LeftValue, Left, Right>>
 Chain operator+(const GenImpl<LeftValue, Left>& left,
                 const GenImpl<RightValue, Right>& right) {
   static_assert(
@@ -207,11 +208,12 @@ Chain operator+(const GenImpl<LeftValue, Left>& left,
   return Chain(left.self(), right.self());
 }
 
-template<class LeftValue,
-         class Left,
-         class RightValue,
-         class Right,
-         class Chain = detail::Chain<LeftValue, Left, Right>>
+template <
+    class LeftValue,
+    class Left,
+    class RightValue,
+    class Right,
+    class Chain = detail::Chain<LeftValue, Left, Right>>
 Chain operator+(const GenImpl<LeftValue, Left>& left,
                 GenImpl<RightValue, Right>&& right) {
   static_assert(
@@ -220,11 +222,12 @@ Chain operator+(const GenImpl<LeftValue, Left>& left,
   return Chain(left.self(), std::move(right.self()));
 }
 
-template<class LeftValue,
-         class Left,
-         class RightValue,
-         class Right,
-         class Chain = detail::Chain<LeftValue, Left, Right>>
+template <
+    class LeftValue,
+    class Left,
+    class RightValue,
+    class Right,
+    class Chain = detail::Chain<LeftValue, Left, Right>>
 Chain operator+(GenImpl<LeftValue, Left>&& left,
                 const GenImpl<RightValue, Right>& right) {
   static_assert(
@@ -233,11 +236,12 @@ Chain operator+(GenImpl<LeftValue, Left>&& left,
   return Chain(std::move(left.self()), right.self());
 }
 
-template<class LeftValue,
-         class Left,
-         class RightValue,
-         class Right,
-         class Chain = detail::Chain<LeftValue, Left, Right>>
+template <
+    class LeftValue,
+    class Left,
+    class RightValue,
+    class Right,
+    class Chain = detail::Chain<LeftValue, Left, Right>>
 Chain operator+(GenImpl<LeftValue, Left>&& left,
                 GenImpl<RightValue, Right>&& right) {
   static_assert(
@@ -250,9 +254,7 @@ Chain operator+(GenImpl<LeftValue, Left>&& left,
  * operator|() which enables foreach-like usage:
  *   gen | [](Value v) -> void {...};
  */
-template<class Value,
-         class Gen,
-         class Handler>
+template <class Value, class Gen, class Handler>
 typename std::enable_if<
   IsCompatibleSignature<Handler, void(Value)>::value>::type
 operator|(const GenImpl<Value, Gen>& gen, Handler&& handler) {
@@ -265,9 +267,7 @@ operator|(const GenImpl<Value, Gen>& gen, Handler&& handler) {
  * operator|() which enables foreach-like usage with 'break' support:
  *   gen | [](Value v) -> bool { return shouldContinue(); };
  */
-template<class Value,
-         class Gen,
-         class Handler>
+template <class Value, class Gen, class Handler>
 typename std::enable_if<
   IsCompatibleSignature<Handler, bool(Value)>::value, bool>::type
 operator|(const GenImpl<Value, Gen>& gen, Handler&& handler) {
@@ -279,17 +279,13 @@ operator|(const GenImpl<Value, Gen>& gen, Handler&& handler) {
  * adaptors:
  *   gen | map(square) | sum
  */
-template<class Value,
-         class Gen,
-         class Op>
+template <class Value, class Gen, class Op>
 auto operator|(const GenImpl<Value, Gen>& gen, const Operator<Op>& op) ->
 decltype(op.self().compose(gen.self())) {
   return op.self().compose(gen.self());
 }
 
-template<class Value,
-         class Gen,
-         class Op>
+template <class Value, class Gen, class Op>
 auto operator|(GenImpl<Value, Gen>&& gen, const Operator<Op>& op) ->
 decltype(op.self().compose(std::move(gen.self()))) {
   return op.self().compose(std::move(gen.self()));
@@ -308,8 +304,7 @@ namespace detail {
  *
  *  auto valuesIncluded = from(optionals) | valuesOf | as<vector>();
  */
-template<class First,
-         class Second>
+template <class First, class Second>
 class Composed : public Operator<Composed<First, Second>> {
   First first_;
   Second second_;
@@ -320,22 +315,24 @@ class Composed : public Operator<Composed<First, Second>> {
     : first_(std::move(first))
     , second_(std::move(second)) {}
 
-  template<class Source,
-           class Value,
-           class FirstRet = decltype(std::declval<First>()
-                                     .compose(std::declval<Source>())),
-           class SecondRet = decltype(std::declval<Second>()
-                                      .compose(std::declval<FirstRet>()))>
+  template <
+      class Source,
+      class Value,
+      class FirstRet =
+          decltype(std::declval<First>().compose(std::declval<Source>())),
+      class SecondRet =
+          decltype(std::declval<Second>().compose(std::declval<FirstRet>()))>
   SecondRet compose(const GenImpl<Value, Source>& source) const {
     return second_.compose(first_.compose(source.self()));
   }
 
-  template<class Source,
-           class Value,
-           class FirstRet = decltype(std::declval<First>()
-                                     .compose(std::declval<Source>())),
-           class SecondRet = decltype(std::declval<Second>()
-                                      .compose(std::declval<FirstRet>()))>
+  template <
+      class Source,
+      class Value,
+      class FirstRet =
+          decltype(std::declval<First>().compose(std::declval<Source>())),
+      class SecondRet =
+          decltype(std::declval<Second>().compose(std::declval<FirstRet>()))>
   SecondRet compose(GenImpl<Value, Source>&& source) const {
     return second_.compose(first_.compose(std::move(source.self())));
   }
@@ -349,7 +346,7 @@ class Composed : public Operator<Composed<First, Second>> {
  *   auto nums = seq(1, 10) + seq(20, 30);
  *   int total = nums | sum;
  */
-template<class Value, class First, class Second>
+template <class Value, class First, class Second>
 class Chain : public GenImpl<Value,
                              Chain<Value, First, Second>> {
   First first_;
@@ -359,13 +356,13 @@ public:
       : first_(std::move(first))
       , second_(std::move(second)) {}
 
-  template<class Handler>
+  template <class Handler>
   bool apply(Handler&& handler) const {
     return first_.apply(std::forward<Handler>(handler))
         && second_.apply(std::forward<Handler>(handler));
   }
 
-  template<class Body>
+  template <class Body>
   void foreach(Body&& body) const {
     first_.foreach(std::forward<Body>(body));
     second_.foreach(std::forward<Body>(body));