14 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FUNCTION_H 15 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FUNCTION_H 17 #include "llvm/ADT/FunctionExtras.h" 18 #include "llvm/Support/Error.h" 28 using Callback = llvm::unique_function<void(llvm::Expected<T>)>;
36 using Tuple = std::tuple<typename std::decay<Func>::type,
37 typename std::decay<Args>::type...>;
45 : FuncWithArguments(std::move(FuncWithArguments)) {}
48 template <std::size_t... Indexes,
class... RestArgs>
49 auto CallImpl(llvm::integer_sequence<std::size_t, Indexes...> Seq,
51 -> decltype(std::get<0>(this->FuncWithArguments)(
52 std::forward<Args>(std::get<Indexes + 1>(this->FuncWithArguments))...,
53 std::forward<RestArgs>(Rest)...)) {
55 std::forward<Args>(std::get<Indexes + 1>(this->FuncWithArguments))...,
56 std::forward<RestArgs>(Rest)...);
60 template <
class... RestArgs>
62 -> decltype(this->CallImpl(llvm::index_sequence_for<Args...>(),
63 std::forward<RestArgs>(Rest)...)) {
66 assert(!WasCalled &&
"Can only call result of Bind once.");
69 return CallImpl(llvm::index_sequence_for<Args...>(),
70 std::forward<RestArgs>(Rest)...);
80 template <
class Func,
class... Args>
83 std::make_tuple(std::forward<Func>(F), std::forward<Args>(As)...));
llvm::unique_function< void(llvm::Expected< T >)> Callback
A Callback<T> is a void function that accepts Expected<T>.
ForwardBinder< Func, Args... > Bind(Func F, Args &&... As)
Creates an object that stores a callable (F) and first arguments to the callable (As) and allows to c...
ForwardBinder(Tuple FuncWithArguments)
std::tuple< typename std::decay< Func >::type, typename std::decay< Args >::type... > Tuple
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Stores a callable object (Func) and arguments (Args) and allows to call the callable with provided ar...
auto operator()(RestArgs &&... Rest) -> decltype(this->CallImpl(llvm::index_sequence_for< Args... >(), std::forward< RestArgs >(Rest)...))