[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)
Nikolas Klauser via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Jun 7 05:43:09 PDT 2024
================
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 _LIBCPP___FUNCTIONAL_MOVE_ONLY_FUNCTION_COMMON_H
+#define _LIBCPP___FUNCTIONAL_MOVE_ONLY_FUNCTION_COMMON_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class...>
+class move_only_function;
+
+template <class>
+struct __is_move_only_function : false_type {};
+
+template <class... _Args>
+struct __is_move_only_function<move_only_function<_Args...>> : true_type {};
+
+template <class _BufferT, class _ReturnT, class... _ArgTypes>
+struct _MoveOnlyFunctionTrivialVTable {
+ using _CallFunc = _ReturnT(_BufferT&, _ArgTypes...);
+
+ _CallFunc* __call_;
+};
+
+template <class _BufferT, class _ReturnT, class... _ArgTypes>
+struct _MoveOnlyFunctionNonTrivialVTable : _MoveOnlyFunctionTrivialVTable<_BufferT, _ReturnT, _ArgTypes...> {
----------------
philnik777 wrote:
The call function pointer is in the base class though. I always want the call pointer and only sometimes the destructor pointer.
https://github.com/llvm/llvm-project/pull/94670
More information about the llvm-branch-commits
mailing list