15#ifndef LLVM_ADT_STLFUNCTIONALEXTRAS_H
16#define LLVM_ADT_STLFUNCTIONALEXTRAS_H
39template<
typename Ret,
typename ...Params>
41 Ret (*callback)(intptr_t callable, Params ...params) =
nullptr;
44 template<
typename Callable>
45 static Ret callback_fn(intptr_t callable, Params ...params) {
46 return (*
reinterpret_cast<Callable*
>(callable))(
47 std::forward<Params>(params)...);
54 template <
typename Callable>
61 std::enable_if_t<std::is_void<Ret>::value ||
62 std::is_convertible<
decltype(std::declval<Callable>()(
63 std::declval<Params>()...)),
65 : callback(callback_fn<
std::remove_reference_t<Callable>>),
66 callable(reinterpret_cast<intptr_t>(&callable)) {}
69 return callback(callable, std::forward<Params>(params)...);
72 explicit operator bool()
const {
return callback; }
75 return callable ==
Other.callable;
#define LLVM_LIFETIME_BOUND
Given that RA is a live value
This file contains library features backported from future STL versions.
bool operator==(const function_ref< Ret(Params...)> &Other) const
function_ref(Callable &&callable LLVM_LIFETIME_BOUND, 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.