1 #ifndef SIPLASPLAS_REFLECTION_STATIC_FUNCTION_HPP 2 #define SIPLASPLAS_REFLECTION_STATIC_FUNCTION_HPP 6 namespace static_reflection
11 template<
typename SourceInfo,
typename FunctionType, FunctionType function>
14 #ifndef SIPLASPLAS_RUNNING_DOXYGEN 15 template<
typename SourceInfo_,
typename R,
typename... Args,
16 R(*
function)(Args...)>
17 class Function<SourceInfo_, R(*)(Args...),
function>
30 using type = R(*)(Args...);
43 template<
typename... Args_>
44 static constexpr R
invoke(Args_&&... args)
46 return function(std::forward<Args_>(args)...);
52 static constexpr
type get()
62 template<
typename... Args_>
65 return invoke(std::forward<Args_>(args)...);
69 #ifndef SIPLASPLAS_RUNNING_DOXYGEN 70 template<
typename SourceInfo_,
typename R,
typename Class,
typename... Args,
71 R(Class::*method)(Args...)
const>
72 class Function<SourceInfo_, R(Class::*)(Args...) const, method>
79 #endif // SIPLASPLAS_RUNNING_DOXYGEN 85 using type = R(Class::*)(Args...)
const;
102 template<
typename... Args_>
103 static constexpr R
invoke(
const Class&
object, Args_&&... args)
105 return object.*method(std::forward<Args_>(args)...);
111 static constexpr
type get()
121 template<
typename... Args_>
122 constexpr R
operator()(
const Class&
object, Args_&&... args)
const 124 return invoke(
object, std::forward<Args_>(args)...);
128 #ifndef SIPLASPLAS_DOXYGEN_RUNNING 129 template<
typename SourceInfo_,
typename R,
typename Class,
typename... Args,
130 R(Class::*method)(Args...)>
131 class Function<SourceInfo_, R(Class::*)(Args...), method>
138 #endif // SIPLASPLAS_DOXYGEN_RUNNING 144 using type = R(Class::*)(Args...);
161 template<
typename... Args_>
162 static constexpr R
invoke(Class&
object, Args_&&... args)
164 return (
object.*method)(std::forward<Args_>(args)...);
172 template<
typename... Args_>
173 static constexpr R
invoke(
const Class&
object, Args_&&... args)
175 return (
object.*method)(std::forward<Args_>(args)...);
191 template<
typename... Args_>
192 constexpr R
operator()(
const Class&
object, Args_&&... args)
const 194 return invoke(
object, std::forward<Args_>(args)...);
202 template<
typename... Args_>
205 return invoke(
object, std::forward<Args_>(args)...);
214 template<
typename FunctionType, FunctionType function>
217 static_reflection::meta::EmptySourceInfo<Function<FunctionType, function>>,
223 template<
typename... Fs>
224 class OverloadedFunction;
226 template<
typename Head>
227 class OverloadedFunction<Head> :
public Head
230 template<
typename Head,
typename Second,
typename... Tail>
231 class OverloadedFunction<Head, Second, Tail...> :
public Head,
public OverloadedFunction<Second, Tail...>
236 using Head::operator();
237 using OverloadedFunction<Second, Tail...>
::invoke;
238 using OverloadedFunction<Second, Tail...>::operator();
241 template<
typename Method>
245 BindedMethod(
typename Method::class_type&
object) :
249 template<
typename... Args>
250 auto operator()(Args&&... args) -> decltype(
Method::invoke(*std::declval<typename Method::class_type*>(), std::forward<Args>(args)...))
256 typename Method::class_type* _object;
259 template<
typename Method>
260 class ConstBindedMethod
263 ConstBindedMethod(
const typename Method::class_type&
object) :
267 template<
typename... Args>
268 auto operator()(Args&&... args) -> decltype(
Method::invoke(*std::declval<const typename Method::class_type*>(), std::forward<Args>(args)...))
274 const typename Method::class_type* _object;
288 template<
typename FunctionType, FunctionType function>
289 class Function :
public codegen::Function<FunctionType, function>
294 #endif // SIPLASPLAS_REFLECTION_STATIC_FUNCTION_HPP
Definition: canary_allocator.hpp:7
Returns static reflection information of a function.
Definition: function.hpp:289
decltype(auto) invoke(Callable &&callable, const ::cpp::SimpleAny< Storages > &...args)
Invokes a callable object with the given type-erased arguments.
Definition: invoke.hpp:214