proxygen
filter.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 
20 
21 namespace folly {
22 namespace pushmi {
23 
24 namespace detail {
25 
26 struct filter_fn {
27  private:
28  template <class In, class Predicate>
29  struct on_value_impl {
30  Predicate p_;
31  PUSHMI_TEMPLATE(class Out, class... VN)
32  (requires Receiver<Out>)
33  void operator()(Out& out, VN&&... vn) const {
34  if (p_(as_const(vn)...)) {
35  set_value(out, (VN &&) vn...);
36  }
37  }
38  };
39  template <class In, class Predicate>
40  struct submit_impl {
41  Predicate p_;
42  PUSHMI_TEMPLATE(class Out)
43  (requires Receiver<Out>)
44  auto operator()(Out out) const {
45  return ::folly::pushmi::detail::receiver_from_fn<In>()(
46  std::move(out),
47  // copy 'p' to allow multiple calls to submit
49  }
50  };
51  template <class Predicate>
52  struct adapt_impl {
53  Predicate p_;
54  PUSHMI_TEMPLATE(class In)
55  (requires Sender<In>)
56  auto operator()(In in) const {
58  std::move(in),
59  ::folly::pushmi::detail::submit_transform_out<In>(
61  }
62  };
63 
64  public:
65  PUSHMI_TEMPLATE(class Predicate)
66  (requires SemiMovable<Predicate>)
67  auto operator()(Predicate p) const {
69  }
70 };
71 
72 } // namespace detail
73 
74 namespace operators {
76 } // namespace operators
77 
78 } // namespace pushmi
79 } // namespace folly
PUSHMI_INLINE_VAR constexpr detail::filter_fn filter
Definition: filter.h:75
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
requires requires(::folly::pushmi::invoke(std::declval< F >(), std::get< Is >(std::declval< Tuple >())...))) const expr decltype(auto) apply_impl(F &&f
#define PUSHMI_INLINE_VAR
Definition: concept_def.h:60
PUSHMI_INLINE_VAR constexpr struct folly::pushmi::detail::sender_from_fn sender_from
PUSHMI_INLINE_VAR constexpr struct folly::pushmi::detail::as_const_fn as_const
PUSHMI_INLINE_VAR constexpr __adl::set_value_fn set_value
PUSHMI_TEMPLATE(class In, class Out, bool SenderRequires, bool SingleSenderRequires, bool TimeSingleSenderRequires)(requires Sender< In > &&Receiver< Out >) constexpr bool sender_requires_from()