[llvm] [libc] Add invoke / invoke_result type traits (PR #65750)

Guillaume Chatelet via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 13 06:11:06 PDT 2023


================
@@ -0,0 +1,58 @@
+//===-- invoke type_traits --------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_INVOKE_H
+#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_INVOKE_H
+
+#include "src/__support/CPP/type_traits/decay.h"
+#include "src/__support/CPP/type_traits/is_base_of.h"
+#include "src/__support/CPP/utility/forward.h"
+
+// BEWARE : this implementation is not fully conformant as it doesn't take
+// `cpp::reference_wrapper` into account.
+
+namespace __llvm_libc::cpp {
+
+namespace detail {
+
+// Catch all function types.
+template <class FunctionPtrType> struct invoke_dispatcher {
+  template <class... Args>
+  static auto call(FunctionPtrType &&fun, Args &&...args) {
----------------
gchatelet wrote:

Added a `T` template argument to capture by forwarding reference and guard it so it is the same type as `FunctionPtrType`.

https://github.com/llvm/llvm-project/pull/65750


More information about the llvm-commits mailing list