]> git.proxmox.com Git - ceph.git/blame - ceph/src/rocksdb/third-party/folly/folly/functional/Invoke.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / rocksdb / third-party / folly / folly / functional / Invoke.h
CommitLineData
f67539c2
TL
1// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2// This source code is licensed under both the GPLv2 (found in the
3// COPYING file in the root directory) and Apache 2.0 License
4// (found in the LICENSE.Apache file in the root directory).
5
6#pragma once
7
8#include <folly/Traits.h>
9
10#include <functional>
11#include <type_traits>
12
13namespace folly {
14namespace invoke_detail {
15template <typename F, typename... Args>
16using invoke_result_ = decltype(std::declval<F>()(std::declval<Args>()...));
17
18template <typename Void, typename F, typename... Args>
19struct is_invocable : std::false_type {};
20
21template <typename F, typename... Args>
22struct is_invocable<void_t<invoke_result_<F, Args...>>, F, Args...>
23 : std::true_type {};
24
25template <typename Void, typename R, typename F, typename... Args>
26struct is_invocable_r : std::false_type {};
27
28template <typename R, typename F, typename... Args>
29struct is_invocable_r<void_t<invoke_result_<F, Args...>>, R, F, Args...>
30 : std::is_convertible<invoke_result_<F, Args...>, R> {};
31} // namespace invoke_detail
32
33// mimic: std::is_invocable, C++17
34template <typename F, typename... Args>
35struct is_invocable : invoke_detail::is_invocable<void, F, Args...> {};
36
37// mimic: std::is_invocable_r, C++17
38template <typename R, typename F, typename... Args>
39struct is_invocable_r : invoke_detail::is_invocable_r<void, R, F, Args...> {};
40} // namespace folly