Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libcxx/docs/FeatureTestMacroTable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ Status
------------------------------------------------- -----------------
``__cpp_lib_is_scoped_enum`` ``202011L``
------------------------------------------------- -----------------
``__cpp_lib_move_only_function`` *unimplemented*
``__cpp_lib_move_only_function`` ``202110L``
------------------------------------------------- -----------------
``__cpp_lib_optional`` ``202110L``
------------------------------------------------- -----------------
Expand Down
2 changes: 1 addition & 1 deletion libcxx/docs/Status/Cxx2bPapers.csv
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"`P2136R3 <https://wg21.link/P2136R3>`__","LWG","invoke_r","June 2021","",""
"`P2166R1 <https://wg21.link/P2166R1>`__","LWG","A Proposal to Prohibit std::basic_string and std::basic_string_view construction from nullptr","June 2021","|Complete|","13.0"
"","","","","",""
"`P0288R9 <https://wg21.link/P0288R9>`__","LWG","``any_invocable``","October 2021","",""
"`P0288R9 <https://wg21.link/P0288R9>`__","LWG","``move_only_function``","October 2021","|Complete|","16.0"
"`P0798R8 <https://wg21.link/P0798R8>`__","LWG","Monadic operations for ``std::optional``","October 2021","|Complete|","14.0"
"`P0849R8 <https://wg21.link/P0849R8>`__","LWG","``auto(x)``: ``DECAY_COPY`` in the language","October 2021","|Complete|","14.0"
"`P1072R10 <https://wg21.link/P1072R10>`__","LWG","``basic_string::resize_and_overwrite``","October 2021","|Complete|","14.0"
Expand Down
3 changes: 3 additions & 0 deletions libcxx/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ set(files
__functional/is_transparent.h
__functional/mem_fn.h
__functional/mem_fun_ref.h
__functional/move_only_function.h
__functional/move_only_function_common.h
__functional/move_only_function_impl.h
__functional/not_fn.h
__functional/operations.h
__functional/perfect_forward.h
Expand Down
2 changes: 2 additions & 0 deletions libcxx/include/__config
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@
// The implementation moved to the header, but we still export the symbols from
// the dylib for backwards compatibility.
# define _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10
// Enable clang::trivial_abi for std::move_only_function
# define _LIBCPP_ABI_MOVE_ONLY_FUNCTION_TRIVIAL_ABI
# elif _LIBCPP_ABI_VERSION == 1
# if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF))
// Enable compiling copies of now inline methods into the dylib to support
Expand Down
72 changes: 72 additions & 0 deletions libcxx/include/__functional/move_only_function.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
//===----------------------------------------------------------------------===//
//
// 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_H
#define _LIBCPP___FUNCTIONAL_MOVE_ONLY_FUNCTION_H

#include <__config>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif

#if _LIBCPP_STD_VER > 20

// NOLINTBEGIN(readability-duplicate-include)
# define _LIBCPP_IN_MOVE_ONLY_FUNCTION_H

# include <__functional/move_only_function_impl.h>

# define _LIBCPP_MOVE_ONLY_FUNCTION_REF &
# include <__functional/move_only_function_impl.h>

# define _LIBCPP_MOVE_ONLY_FUNCTION_REF &&
# include <__functional/move_only_function_impl.h>

# define _LIBCPP_MOVE_ONLY_FUNCTION_CV const
# include <__functional/move_only_function_impl.h>

# define _LIBCPP_MOVE_ONLY_FUNCTION_CV const
# define _LIBCPP_MOVE_ONLY_FUNCTION_REF &
# include <__functional/move_only_function_impl.h>

# define _LIBCPP_MOVE_ONLY_FUNCTION_CV const
# define _LIBCPP_MOVE_ONLY_FUNCTION_REF &&
# include <__functional/move_only_function_impl.h>

# define _LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT true
# include <__functional/move_only_function_impl.h>

# define _LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT true
# define _LIBCPP_MOVE_ONLY_FUNCTION_REF &
# include <__functional/move_only_function_impl.h>

# define _LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT true
# define _LIBCPP_MOVE_ONLY_FUNCTION_REF &&
# include <__functional/move_only_function_impl.h>

# define _LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT true
# define _LIBCPP_MOVE_ONLY_FUNCTION_CV const
# include <__functional/move_only_function_impl.h>

# define _LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT true
# define _LIBCPP_MOVE_ONLY_FUNCTION_CV const
# define _LIBCPP_MOVE_ONLY_FUNCTION_REF &
# include <__functional/move_only_function_impl.h>

# define _LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT true
# define _LIBCPP_MOVE_ONLY_FUNCTION_CV const
# define _LIBCPP_MOVE_ONLY_FUNCTION_REF &&
# include <__functional/move_only_function_impl.h>

# undef _LIBCPP_IN_MOVE_ONLY_FUNCTION_H
// NOLINTEND(readability-duplicate-include)

#endif // _LIBCPP_STD_VER > 20

#endif // _LIBCPP___FUNCTIONAL_MOVE_ONLY_FUNCTION_H
32 changes: 32 additions & 0 deletions libcxx/include/__functional/move_only_function_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//===----------------------------------------------------------------------===//
//
// 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 {};

_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP___FUNCTIONAL_MOVE_ONLY_FUNCTION_COMMON_H
Loading