21 #ifndef FUB_CORE_FUNCTION_REF 
   22 #define FUB_CORE_FUNCTION_REF 
   27 #include <type_traits> 
   39 template <
typename F, 
typename... Args>
 
   40 using IsInvocableT_ = decltype(std::declval<F>()(std::declval<Args>()...));
 
   42 template <
typename F, 
typename R, 
typename... Args>
 
   51 template <
typename Ret, 
typename... Params> 
class function_ref<Ret(Params...)> {
 
   52   Ret (*callback)(std::intptr_t callable, Params... params);
 
   55   template <
typename Callable>
 
   56   static Ret 
callback_fn(std::intptr_t callable, Params... params) {
 
   57     return (*
reinterpret_cast<Callable*
>(callable))(
 
   58         std::forward<Params>(params)...);
 
   64       typename = std::enable_if_t<
IsInvocable<Callable, Ret, Params...>::value>>
 
   66                typename std::enable_if<
 
   67                    !std::is_same<
typename std::remove_reference<Callable>::type,
 
   69       : callback(callback_fn<typename std::remove_reference<Callable>::type>),
 
   70         callable(reinterpret_cast<std::intptr_t>(&callable)) {}
 
   72     return callback(callable, std::forward<Params>(params)...);
 
static Ret callback_fn(std::intptr_t callable, Params... params)
Definition: function_ref.hpp:56
 
function_ref(Callable &&callable, typename std::enable_if< !std::is_same< typename std::remove_reference< Callable >::type, function_ref >::value >::type *=nullptr)
Definition: function_ref.hpp:65
 
std::intptr_t callable
Definition: function_ref.hpp:53
 
Ret operator()(Params... params) const
Definition: function_ref.hpp:71
 
An efficient, type-erasing, non-owning reference to a callable.
Definition: function_ref.hpp:37
 
The fub namespace.
Definition: AnyBoundaryCondition.hpp:31
 
decltype(std::declval< F >()(std::declval< Args >()...)) IsInvocableT_
Definition: function_ref.hpp:40
 
Definition: function_ref.hpp:43
 
This is std::true_type if Op<Args...> is a valid SFINAE expression and the return type is exactly Exp...
Definition: type_traits.hpp:108
 
This file adds basic type traits utilities which are not yet implemented in all standard libraries.