15 #ifndef LLVM_ADT_STLFUNCTIONALEXTRAS_H
16 #define LLVM_ADT_STLFUNCTIONALEXTRAS_H
20 #include <type_traits>
38 template<
typename Ret,
typename ...Params>
43 template<
typename Callable>
44 static Ret callback_fn(
intptr_t callable, Params ...params) {
45 return (*
reinterpret_cast<Callable*
>(callable))(
46 std::forward<Params>(params)...);
53 template <
typename Callable>
60 std::enable_if_t<std::is_void<Ret>::value ||
61 std::is_convertible<decltype(std::declval<Callable>()(
62 std::declval<Params>()...)),
63 Ret>::value> * =
nullptr)
64 :
callback(callback_fn<typename
std::remove_reference<Callable>::
type>),
65 callable(reinterpret_cast<
intptr_t>(&callable)) {}
68 return callback(callable, std::forward<Params>(params)...);
71 explicit operator bool()
const {
return callback; }
76 #endif // LLVM_ADT_STLFUNCTIONALEXTRAS_H