6#ifndef MIMICPP_CALL_CONVENTION_HPP
7#define MIMICPP_CALL_CONVENTION_HPP
13#include <source_location>
61#define MIMICPP_DETAIL_DEFINE_REMOVE_CALL_CONVENTION(call_convention, specs) \
62 template <typename Return, typename... Params> \
63 struct remove_call_convention<Return call_convention(Params...) specs> \
65 using type = Return(Params...) specs; \
75#define MIMICPP_DETAIL_DEFINE_ADD_CALL_CONVENTION(call_convention, specs) \
76 template <typename Return, typename... Params> \
77 struct add_call_convention<Return(Params...) specs> \
79 using type = Return call_convention(Params...) specs; \
88#define MIMICPP_DETAIL_DEFINE_CALL_CONVENTION_CALL_INTERFACE(call_convention, specs) \
89 template <typename Derived, typename Return, typename... Params> \
90 class CallInterface< \
92 Return call_convention(Params...) specs> \
95 constexpr Return call_convention operator()( \
97 const ::std::source_location& from = ::std::source_location::current()) specs \
99 return static_cast<const Derived&>(*this) \
100 .handle_call(::std::tuple{::std::ref(params)...}, from); \
110#define MIMICPP_DETAIL_DEFINE_CALL_CONVENTION_SPECIALIZATIONS(call_convention, specs) \
111 MIMICPP_DETAIL_DEFINE_REMOVE_CALL_CONVENTION(call_convention, specs); \
112 MIMICPP_DETAIL_DEFINE_ADD_CALL_CONVENTION(call_convention, specs); \
113 MIMICPP_DETAIL_DEFINE_CALL_CONVENTION_CALL_INTERFACE(call_convention, specs)
123#define MIMICPP_REGISTER_CALL_CONVENTION(call_convention, namespace_name) \
124 namespace namespace_name \
130 inline constexpr bool is_default_call_convention = ::std::same_as<void(), void call_convention()>; \
132 template <typename Signature> \
133 struct remove_call_convention; \
135 template <typename Signature> \
136 using remove_call_convention_t = typename remove_call_convention<Signature>::type; \
138 template <typename Signature> \
139 concept has_call_convention = !std::same_as<Signature, remove_call_convention_t<Signature>>; \
141 template <typename Signature> \
142 struct add_call_convention; \
144 template <typename Signature> \
145 using add_call_convention_t = typename add_call_convention<Signature>::type; \
147 template <has_call_convention Signature> \
148 struct add_call_convention<Signature> \
150 using type = Signature; \
153 template <typename Derived, typename Signature> \
154 class CallInterface; \
156 MIMICPP_DETAIL_DEFINE_CALL_CONVENTION_SPECIALIZATIONS(call_convention, ); \
157 MIMICPP_DETAIL_DEFINE_CALL_CONVENTION_SPECIALIZATIONS(call_convention, noexcept); \
158 MIMICPP_DETAIL_DEFINE_CALL_CONVENTION_SPECIALIZATIONS(call_convention, const); \
159 MIMICPP_DETAIL_DEFINE_CALL_CONVENTION_SPECIALIZATIONS(call_convention, const noexcept); \
160 MIMICPP_DETAIL_DEFINE_CALL_CONVENTION_SPECIALIZATIONS(call_convention, &); \
161 MIMICPP_DETAIL_DEFINE_CALL_CONVENTION_SPECIALIZATIONS(call_convention, & noexcept); \
162 MIMICPP_DETAIL_DEFINE_CALL_CONVENTION_SPECIALIZATIONS(call_convention, const&); \
163 MIMICPP_DETAIL_DEFINE_CALL_CONVENTION_SPECIALIZATIONS(call_convention, const& noexcept); \
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); \
170 template <::namespace_name::has_call_convention Signature> \
171 requires(!::namespace_name::is_default_call_convention) \
172 struct mimicpp::signature_call_convention<Signature> \
174 using type = ::namespace_name::tag; \
180 template <::mimicpp::has_default_call_convention Signature> \
181 requires ::namespace_name::is_default_call_convention \
182 struct mimicpp::signature_call_convention<Signature> \
184 using type = ::namespace_name::tag; \
188 struct mimicpp::call_convention_traits<::namespace_name::tag> \
190 using tag_t = ::namespace_name::tag; \
192 template <typename Signature> \
193 using remove_call_convention_t = ::namespace_name::remove_call_convention_t<Signature>; \
195 template <typename Signature> \
196 using add_call_convention_t = ::namespace_name::add_call_convention_t<Signature>; \
198 template <typename Derived, typename Signature> \
199 using call_interface_t = ::namespace_name::CallInterface<Derived, Signature>; \
Definition BoostTest.hpp:20