proxygen
functional.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 
18 #include <functional>
19 
21 
22 namespace folly {
23 namespace pushmi {
24 
25 PUSHMI_INLINE_VAR constexpr struct invoke_fn {
26  private:
27  template <class F>
28  using mem_fn_t = decltype(std::mem_fn(std::declval<F>()));
29 
30  public:
31  template <class F, class... As>
32  auto operator()(F&& f, As&&... as) const
33  noexcept(noexcept(((F &&) f)((As &&) as...)))
34  -> decltype(((F &&) f)((As &&) as...)) {
35  return ((F &&) f)((As &&) as...);
36  }
37  template <class F, class... As>
38  auto operator()(F&& f, As&&... as) const
39  noexcept(noexcept(std::declval<mem_fn_t<F>>()((As &&) as...)))
40  -> decltype(std::mem_fn(f)((As &&) as...)) {
41  return std::mem_fn(f)((As &&) as...);
42  }
43 } invoke{};
44 
45 template <class F, class... As>
46 using invoke_result_t =
47  decltype(folly::pushmi::invoke(std::declval<F>(), std::declval<As>()...));
48 
50  template (class F, class... Args)
51  (concept Invocable)(F, Args...),
52  requires(F&& f) (
53  ::folly::pushmi::invoke((F &&) f, std::declval<Args>()...)
54  )
55 );
56 
58  template (class F, class... Args)
59  (concept NothrowInvocable)(F, Args...),
60  requires(F&& f) (
61  requires_<noexcept(::folly::pushmi::invoke((F &&) f, std::declval<Args>()...))>
62  ) &&
63  Invocable<F, Args...>
64 );
65 
66 } // namespace pushmi
67 } // namespace folly
decltype(std::mem_fn(std::declval< F >())) mem_fn_t
Definition: functional.h:28
PUSHMI_INLINE_VAR constexpr struct folly::pushmi::invoke_fn invoke
auto f
constexpr std::enable_if_t< B, int > requires_
Definition: concept_def.h:554
STL namespace.
internal::ArgsMatcher< InnerMatcher > Args(const InnerMatcher &matcher)
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
requires E e noexcept(noexcept(s.error(std::move(e))))
PUSHMI_CONCEPT_DEF(template(class PS) concept Cardinality, has_cardinality_v< PS >)
#define concept
auto operator()(F &&f, As &&...as) const noexcept(noexcept(std::declval< mem_fn_t< F >>()((As &&) as...))) -> decltype(std::mem_fn(f)((As &&) as...))
Definition: functional.h:38
#define PUSHMI_INLINE_VAR
Definition: concept_def.h:60
auto operator()(F &&f, As &&...as) const noexcept(noexcept(((F &&) f)((As &&) as...))) -> decltype(((F &&) f)((As &&) as...))
Definition: functional.h:32
requires requires(detail::apply_impl(std::declval< F >(), std::declval< Tuple >(), detail::tupidxs< Tuple >{}))) const expr decltype(auto) apply(F &&f
const
Definition: upload.py:398
decltype(folly::pushmi::invoke(std::declval< F >(), std::declval< As >()...)) invoke_result_t
Definition: functional.h:47
Collect as()
Definition: Base.h:811