32#ifndef LLVM_ADT_FUNCTIONEXTRAS_H
33#define LLVM_ADT_FUNCTIONEXTRAS_H
59template <
typename CallableT,
typename ThisT>
61 std::enable_if_t<!std::is_same<remove_cvref_t<CallableT>, ThisT>
::value>;
62template <
typename CallableT,
typename Ret,
typename... Params>
65 std::is_same<decltype(std::declval<CallableT>()(std::declval<Params>()...)),
67 std::is_same<
const decltype(std::declval<CallableT>()(
68 std::declval<Params>()...)),
70 std::is_convertible<
decltype(std::declval<CallableT>()(
71 std::declval<Params>()...)),
89 static_assert(!std::is_reference<T>::value,
90 "references should be handled by template specialization");
92 sizeof(
T) <= 2 *
sizeof(
void *);
94 std::conditional_t<std::is_trivially_copy_constructible<T>::value &&
95 std::is_trivially_move_constructible<T>::value &&
106 template <
typename T>
123 "Should always use all of the out-of-line storage for inline storage!");
141 template <
typename CallableT,
typename CalledAsT>
144 static constexpr bool UsesInlineStorage =
147 void *CallableAddr = &
Storage.Inline;
148 if constexpr (!UsesInlineStorage) {
150 Storage.OutOfLine = CallableAddr;
154 new (CallableAddr) CallableT(std::move(Callable));
160 auto &Func = *
reinterpret_cast<CalledAsT *
>(CallableAddr);
161 return Func(std::forward<ParamTs>(Params)...);
165 if constexpr (!std::is_trivially_move_constructible_v<CallableT> ||
166 !std::is_trivially_destructible_v<CallableT> ||
167 !UsesInlineStorage) {
170 if constexpr (!UsesInlineStorage) {
173 LHS->Storage.OutOfLine =
RHS->Storage.OutOfLine;
176 void *RHSCallableAddr =
RHS->Storage.OutOfLine;
177 reinterpret_cast<CallableT *
>(RHSCallableAddr)->~CallableT();
183 reinterpret_cast<CallableT *
>(&
RHS->Storage.Inline);
187 reinterpret_cast<CallableT *
>(&
LHS->Storage.Inline);
188 new (LHSCallable) CallableT(std::move(*RHSCallable));
191 RHSCallable->~CallableT();
210 RHS.CallPtr =
nullptr;
211 RHS.DestroyMovePtr =
nullptr;
238template <
typename R,
typename...
P>
250 template <
typename CallableT>
255 : Base(
std::forward<CallableT>(Callable),
256 typename Base::template CalledAs<CallableT>{}) {}
261template <
typename R,
typename...
P>
274 template <
typename CallableT>
279 : Base(
std::forward<CallableT>(Callable),
280 typename Base::template CalledAs<
const CallableT>{}) {}
This file defines counterparts of C library allocation functions defined in the namespace 'std'.
This file defines the PointerIntPair class.
This file defines the PointerUnion class, which is a discriminated union of pointer types.
This file contains library features backported from future STL versions.
UniqueFunctionBase()=default
ReturnT(*)(const UniqueFunctionBase *Self, AdjustedParamT< ParamTs >... Params) CallPtrT
UniqueFunctionBase & operator=(UniqueFunctionBase &&RHS) noexcept
typename AdjustedParamTBase< T >::type AdjustedParamT
UniqueFunctionBase(CallableT Callable, CalledAs< CalledAsT >)
union llvm::detail::UniqueFunctionBase::StorageT Storage
static constexpr size_t InlineStorageAlign
void(*)(UniqueFunctionBase *LHS, UniqueFunctionBase *RHS) DestroyMovePtrT
UniqueFunctionBase(UniqueFunctionBase &&RHS) noexcept
DestroyMovePtrT DestroyMovePtr
static constexpr size_t InlineStorageSize
unique_function(std::nullptr_t)
unique_function()=default
unique_function(const unique_function &)=delete
unique_function(unique_function &&)=default
unique_function & operator=(const unique_function &)=delete
unique_function & operator=(unique_function &&)=default
R operator()(P... Params) const
unique_function(CallableT Callable, detail::EnableUnlessSameType< CallableT, unique_function > *=nullptr, detail::EnableIfCallable< const CallableT, R, P... > *=nullptr)
unique_function(unique_function &&)=default
unique_function & operator=(const unique_function &)=delete
unique_function(CallableT Callable, detail::EnableUnlessSameType< CallableT, unique_function > *=nullptr, detail::EnableIfCallable< CallableT, R, P... > *=nullptr)
unique_function & operator=(unique_function &&)=default
R operator()(P... Params)
unique_function()=default
unique_function(std::nullptr_t)
unique_function(const unique_function &)=delete
unique_function is a type-erasing functor similar to std::function.
std::enable_if_t<!std::is_same< remove_cvref_t< CallableT >, ThisT >::value > EnableUnlessSameType
const char unit< Period >::value[]
std::enable_if_t< std::disjunction< std::is_void< Ret >, std::is_same< decltype(std::declval< CallableT >()(std::declval< Params >()...)), Ret >, std::is_same< const decltype(std::declval< CallableT >()( std::declval< Params >()...)), Ret >, std::is_convertible< decltype(std::declval< CallableT >()( std::declval< Params >()...)), Ret > >::value > EnableIfCallable
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * allocate_buffer(size_t Size, size_t Alignment)
Allocate a buffer of memory with the given size and alignment.
LLVM_ABI void deallocate_buffer(void *Ptr, size_t Size, size_t Alignment)
Deallocate a buffer of memory with the given size and alignment.
Implement std::hash so that hash_code can be used in STL containers.
std::conditional_t< std::is_trivially_copy_constructible< T >::value && std::is_trivially_move_constructible< T >::value && IsSizeLessThanThreshold, T, T & > type
static constexpr bool IsSizeLessThanThreshold
std::byte Inline[InlineStorageSize]