15#ifndef LLVM_ADT_STLFUNCTIONALEXTRAS_H
16#define LLVM_ADT_STLFUNCTIONALEXTRAS_H
38template<
typename Ret,
typename ...Params>
40 Ret (*callback)(intptr_t callable, Params ...params) =
nullptr;
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>()...)),
64 : callback(callback_fn<
std::remove_reference_t<Callable>>),
65 callable(reinterpret_cast<intptr_t>(&callable)) {}
68 return callback(callable, std::forward<Params>(params)...);
71 explicit operator bool()
const {
return callback; }
Given that RA is a live value
This file contains library features backported from future STL versions.
function_ref(Callable &&callable, std::enable_if_t<!std::is_same< remove_cvref_t< Callable >, function_ref >::value > *=nullptr, std::enable_if_t< std::is_void< Ret >::value||std::is_convertible< decltype(std::declval< Callable >()(std::declval< Params >()...)), Ret >::value > *=nullptr)
function_ref(std::nullptr_t)
Ret operator()(Params ...params) const
An efficient, type-erasing, non-owning reference to a callable.
This is an optimization pass for GlobalISel generic memory operations.
Implement std::hash so that hash_code can be used in STL containers.