LLVM 22.0.0git
FunctionExtras.h File Reference

This file provides a collection of function (or more generally, callable) type erasure utilities supplementing those provided by the standard library in <function>. More...

#include "llvm/ADT/PointerIntPair.h"
#include "llvm/ADT/PointerUnion.h"
#include "llvm/ADT/STLForwardCompat.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/MemAlloc.h"
#include "llvm/Support/type_traits.h"
#include <cstring>
#include <memory>
#include <type_traits>

Go to the source code of this file.

Classes

class  llvm::detail::UniqueFunctionBase< ReturnT, ParamTs >
struct  llvm::detail::UniqueFunctionBase< ReturnT, ParamTs >::AdjustedParamTBase< T >
struct  llvm::detail::UniqueFunctionBase< ReturnT, ParamTs >::AdjustedParamTBase< T & >
struct  llvm::detail::UniqueFunctionBase< ReturnT, ParamTs >::AdjustedParamTBase< T && >
struct  llvm::detail::UniqueFunctionBase< ReturnT, ParamTs >::TrivialCallback
 A struct to hold a single trivial callback with sufficient alignment for our bitpacking. More...
struct  llvm::detail::UniqueFunctionBase< ReturnT, ParamTs >::NonTrivialCallbacks
 A struct we use to aggregate three callbacks when we need full set of operations. More...
union  llvm::detail::UniqueFunctionBase< ReturnT, ParamTs >::StorageUnionT
struct  llvm::detail::UniqueFunctionBase< ReturnT, ParamTs >::StorageUnionT::OutOfLineStorageT
struct  llvm::detail::UniqueFunctionBase< ReturnT, ParamTs >::CallbacksHolder< CallableT, CalledAs >
struct  llvm::detail::UniqueFunctionBase< ReturnT, ParamTs >::CalledAs< T >
class  llvm::unique_function< R(P...)>
class  llvm::unique_function< R(P...) const >

Namespaces

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.
namespace  llvm::detail
 These are wrappers over isa* function that allow them to be used in generic algorithms such as llvm:all_of, llvm::none_of, etc.

Typedefs

template<typename CallableT, typename ThisT>
using llvm::detail::EnableUnlessSameType
template<typename CallableT, typename Ret, typename... Params>
using llvm::detail::EnableIfCallable

Detailed Description

This file provides a collection of function (or more generally, callable) type erasure utilities supplementing those provided by the standard library in <function>.

It provides unique_function, which works like std::function but supports move-only callable objects and const-qualification.

Future plans:

  • Add a function that provides ref-qualified support, which doesn't work with std::function.
  • Provide support for specifying multiple signatures to type erase callable objects with an overload set, such as those produced by generic lambdas.
  • Expand to include a copyable utility that directly replaces std::function but brings the above improvements.

Note that LLVM's utilities are greatly simplified by not supporting allocators.

If the standard library ever begins to provide comparable facilities we can consider switching to those.

Definition in file FunctionExtras.h.