LLVM 22.0.0git
CallableTraitsHelper.h
Go to the documentation of this file.
1//===- CallableTraitsHelper.h - Callable arg/ret type extractor -*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// CallableTraitsHelper API.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_EXECUTIONENGINE_ORC_CALLABLETRAITSHELPER_H
14#define LLVM_EXECUTIONENGINE_ORC_CALLABLETRAITSHELPER_H
15
16#include <tuple>
17#include <type_traits>
18
19namespace llvm::orc {
20
21/// CallableTraitsHelper takes an implementation class template Impl and some
22/// callable type C and passes the return and argument types of C to the Impl
23/// class template.
24///
25/// This can be used to simplify the implementation of classes that need to
26/// operate on callable types.
27template <template <typename...> typename ImplT, typename C>
29 : public CallableTraitsHelper<
30 ImplT,
31 decltype(&std::remove_cv_t<std::remove_reference_t<C>>::operator())> {
32};
33
34template <template <typename...> typename ImplT, typename RetT,
35 typename... ArgTs>
36struct CallableTraitsHelper<ImplT, RetT(ArgTs...)>
37 : public ImplT<RetT, ArgTs...> {};
38
39template <template <typename...> typename ImplT, typename RetT,
40 typename... ArgTs>
41struct CallableTraitsHelper<ImplT, RetT (*)(ArgTs...)>
42 : public CallableTraitsHelper<ImplT, RetT(ArgTs...)> {};
43
44template <template <typename...> typename ImplT, typename RetT,
45 typename... ArgTs>
46struct CallableTraitsHelper<ImplT, RetT (&)(ArgTs...)>
47 : public CallableTraitsHelper<ImplT, RetT(ArgTs...)> {};
48
49template <template <typename...> typename ImplT, typename ClassT, typename RetT,
50 typename... ArgTs>
51struct CallableTraitsHelper<ImplT, RetT (ClassT::*)(ArgTs...)>
52 : public CallableTraitsHelper<ImplT, RetT(ArgTs...)> {};
53
54template <template <typename...> typename ImplT, typename ClassT, typename RetT,
55 typename... ArgTs>
56struct CallableTraitsHelper<ImplT, RetT (ClassT::*)(ArgTs...) const>
57 : public CallableTraitsHelper<ImplT, RetT(ArgTs...)> {};
58
59namespace detail {
60template <typename RetT, typename... ArgTs> struct CallableArgInfoImpl {
61 using ReturnType = RetT;
62 using ArgsTupleType = std::tuple<ArgTs...>;
63};
64} // namespace detail
65
66/// CallableArgInfo provides typedefs for the return type and argument types
67/// (as a tuple) of the given callable type.
68template <typename Callable>
70 : public CallableTraitsHelper<detail::CallableArgInfoImpl, Callable> {};
71
72} // namespace llvm::orc
73
74#endif // LLVM_EXECUTIONENGINE_ORC_CALLABLETRAITSHELPER_H
aarch64 promote const
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
CallableArgInfo provides typedefs for the return type and argument types (as a tuple) of the given ca...
CallableTraitsHelper takes an implementation class template Impl and some callable type C and passes ...