Loading...
Searching...
No Matches
Go to the documentation of this file.
6#ifndef MIMICPP_CALL_CONVENTION_HPP
7#define MIMICPP_CALL_CONVENTION_HPP
15#ifndef MIMICPP_DETAIL_IS_MODULE
66#define MIMICPP_DETAIL_DEFINE_REMOVE_CALL_CONVENTION(call_convention, specs) \
67 template <typename Return, typename... Params> \
68 struct remove_call_convention<Return call_convention(Params...) specs> \
70 using type = Return(Params...) specs; \
80#define MIMICPP_DETAIL_DEFINE_ADD_CALL_CONVENTION(call_convention, specs) \
81 template <typename Return, typename... Params> \
82 struct add_call_convention<Return(Params...) specs> \
84 using type = Return call_convention(Params...) specs; \
93#define MIMICPP_DETAIL_DEFINE_CALL_CONVENTION_CALL_INTERFACE(call_convention, specs) \
94 template <typename Derived, typename Return, typename... Params> \
95 class CallInterface< \
97 Return call_convention(Params...) specs> \
100 constexpr Return call_convention operator()( \
102 ::mimicpp::util::SourceLocation from = {}) specs \
104 return static_cast<Derived const&>(*this) \
106 ::mimicpp::reporting::TypeReport::make<Return(Params...) specs>(), \
107 ::std::tuple{::std::ref(params)...}, \
108 ::std::move(from)); \
118#define MIMICPP_DETAIL_DEFINE_CALL_CONVENTION_SPECIALIZATIONS(call_convention, specs) \
119 MIMICPP_DETAIL_DEFINE_REMOVE_CALL_CONVENTION(call_convention, specs); \
120 MIMICPP_DETAIL_DEFINE_ADD_CALL_CONVENTION(call_convention, specs); \
121 MIMICPP_DETAIL_DEFINE_CALL_CONVENTION_CALL_INTERFACE(call_convention, specs)
131#define MIMICPP_REGISTER_CALL_CONVENTION(call_convention, namespace_name) \
132 namespace namespace_name \
138 constexpr bool is_default_call_convention = ::std::same_as<void(), void call_convention()>; \
140 template <typename Signature> \
141 struct remove_call_convention; \
143 template <typename Signature> \
144 using remove_call_convention_t = typename remove_call_convention<Signature>::type; \
146 template <typename Signature> \
147 concept has_call_convention = !::std::same_as<Signature, remove_call_convention_t<Signature>>; \
149 template <typename Signature> \
150 struct add_call_convention; \
152 template <typename Signature> \
153 using add_call_convention_t = typename add_call_convention<Signature>::type; \
155 template <has_call_convention Signature> \
156 struct add_call_convention<Signature> \
158 using type = Signature; \
161 template <typename Derived, typename Signature> \
162 class CallInterface; \
164 MIMICPP_DETAIL_DEFINE_CALL_CONVENTION_SPECIALIZATIONS(call_convention, ); \
165 MIMICPP_DETAIL_DEFINE_CALL_CONVENTION_SPECIALIZATIONS(call_convention, noexcept); \
166 MIMICPP_DETAIL_DEFINE_CALL_CONVENTION_SPECIALIZATIONS(call_convention, const); \
167 MIMICPP_DETAIL_DEFINE_CALL_CONVENTION_SPECIALIZATIONS(call_convention, const noexcept); \
168 MIMICPP_DETAIL_DEFINE_CALL_CONVENTION_SPECIALIZATIONS(call_convention, &); \
169 MIMICPP_DETAIL_DEFINE_CALL_CONVENTION_SPECIALIZATIONS(call_convention, & noexcept); \
170 MIMICPP_DETAIL_DEFINE_CALL_CONVENTION_SPECIALIZATIONS(call_convention, const&); \
171 MIMICPP_DETAIL_DEFINE_CALL_CONVENTION_SPECIALIZATIONS(call_convention, const& noexcept); \
172 MIMICPP_DETAIL_DEFINE_CALL_CONVENTION_SPECIALIZATIONS(call_convention, &&); \
173 MIMICPP_DETAIL_DEFINE_CALL_CONVENTION_SPECIALIZATIONS(call_convention, && noexcept); \
174 MIMICPP_DETAIL_DEFINE_CALL_CONVENTION_SPECIALIZATIONS(call_convention, const&&); \
175 MIMICPP_DETAIL_DEFINE_CALL_CONVENTION_SPECIALIZATIONS(call_convention, const&& noexcept); \
180 template <::namespace_name::has_call_convention Signature> \
181 requires(!::namespace_name::is_default_call_convention) \
182 struct signature_call_convention<Signature> \
184 using type = ::namespace_name::tag; \
190 template <::mimicpp::has_default_call_convention Signature> \
191 requires ::namespace_name::is_default_call_convention \
192 struct signature_call_convention<Signature> \
194 using type = ::namespace_name::tag; \
198 struct call_convention_traits<::namespace_name::tag> \
200 using tag_t = ::namespace_name::tag; \
202 template <typename Signature> \
203 using remove_call_convention_t = ::namespace_name::remove_call_convention_t<Signature>; \
205 template <typename Signature> \
206 using add_call_convention_t = ::namespace_name::add_call_convention_t<Signature>; \
208 template <typename Derived, typename Signature> \
209 using call_interface_t = ::namespace_name::CallInterface<Derived, Signature>; \