proxygen
reduce.h
Go to the documentation of this file.
1 /*
2  * Copyright 2018-present Facebook, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
17 
21 
22 namespace folly {
23 namespace pushmi {
24 
25 PUSHMI_INLINE_VAR constexpr struct reduce_fn {
26  private:
27  template <class BinaryOp>
28  struct fn {
29  BinaryOp binary_op_;
30  template <class Acc, class Cursor>
31  void operator()(Acc& acc, Cursor cursor) const {
32  acc = binary_op_(acc, *cursor);
33  }
34  };
35  struct identity {
36  template <class T>
37  auto operator()(T&& t) const {
38  return (T &&) t;
39  }
40  };
41 
42  public:
43  template <class ExecutionPolicy, class ForwardIt, class T, class BinaryOp>
45  ExecutionPolicy&& policy,
46  ForwardIt begin,
47  ForwardIt end,
48  T init,
49  BinaryOp binary_op) const {
50  return operators::just(std::move(init)) |
52  fn<BinaryOp>{binary_op},
53  begin,
54  end,
55  policy,
56  identity{},
57  identity{}) |
58  operators::get<T>;
59  }
60 } reduce{};
61 
62 } // namespace pushmi
63 } // namespace folly
requires Tuple && t
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
auto begin(TestAdlIterable &instance)
Definition: ForeachTest.cpp:56
folly::std T
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
void operator()(Acc &acc, Cursor cursor) const
Definition: reduce.h:31
auto operator()(T &&t) const
Definition: reduce.h:37
void init(int *argc, char ***argv, bool removeFlags)
Definition: Init.cpp:34
auto end(TestAdlIterable &instance)
Definition: ForeachTest.cpp:62
#define PUSHMI_INLINE_VAR
Definition: concept_def.h:60
PUSHMI_INLINE_VAR constexpr struct folly::pushmi::operators::bulk_fn bulk
PUSHMI_INLINE_VAR constexpr struct folly::pushmi::operators::just_fn just
PUSHMI_INLINE_VAR constexpr struct folly::pushmi::reduce_fn reduce
T operator()(ExecutionPolicy &&policy, ForwardIt begin, ForwardIt end, T init, BinaryOp binary_op) const
Definition: reduce.h:44