Skip to content
Merged
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
4 changes: 4 additions & 0 deletions libcxx/docs/FeatureTestMacroTable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ Status
---------------------------------------------------------- -----------------
``__cpp_lib_char8_t`` ``201907L``
---------------------------------------------------------- -----------------
``__cpp_lib_common_reference`` ``202302L``
---------------------------------------------------------- -----------------
``__cpp_lib_common_reference_wrapper`` ``202302L``
---------------------------------------------------------- -----------------
``__cpp_lib_concepts`` ``202002L``
---------------------------------------------------------- -----------------
``__cpp_lib_constexpr_algorithms`` ``201806L``
Expand Down
1 change: 1 addition & 0 deletions libcxx/docs/ReleaseNotes/21.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Implemented Papers
- P2441R2: ``views::join_with`` (`Github <https://github.com/llvm/llvm-project/issues/105185>`__)
- P2711R1: Making multi-param constructors of ``views`` ``explicit`` (`Github <https://github.com/llvm/llvm-project/issues/105252>`__)
- P2770R0: Stashing stashing ``iterators`` for proper flattening (`Github <https://github.com/llvm/llvm-project/issues/105250>`__)
- P2655R3: ``common_reference_t`` of ``reference_wrapper`` Should Be a Reference Type (`Github <https://github.com/llvm/llvm-project/issues/105260>`__)

Improvements and New Features
-----------------------------
Expand Down
2 changes: 1 addition & 1 deletion libcxx/docs/Status/Cxx23Papers.csv
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"`P2693R1 <https://wg21.link/P2693R1>`__","Formatting ``thread::id`` and ``stacktrace``","2023-02 (Issaquah)","|Partial|","","The formatter for ``stacktrace`` is not implemented, since ``stacktrace`` is not implemented yet"
"`P2679R2 <https://wg21.link/P2679R2>`__","Fixing ``std::start_lifetime_as`` for arrays","2023-02 (Issaquah)","","",""
"`P2674R1 <https://wg21.link/P2674R1>`__","A trait for implicit lifetime types","2023-02 (Issaquah)","|Complete|","20",""
"`P2655R3 <https://wg21.link/P2655R3>`__","``common_reference_t`` of ``reference_wrapper`` Should Be a Reference Type","2023-02 (Issaquah)","","",""
"`P2655R3 <https://wg21.link/P2655R3>`__","``common_reference_t`` of ``reference_wrapper`` Should Be a Reference Type","2023-02 (Issaquah)","|Complete|","21","The paper is implemented as a DR to C++20"
"`P2652R2 <https://wg21.link/P2652R2>`__","Disallow User Specialization of ``allocator_traits``","2023-02 (Issaquah)","|Complete|","19",""
"`P2787R1 <https://wg21.link/P2787R1>`__","``pmr::generator`` - Promise Types are not Values","2023-02 (Issaquah)","","",""
"`P2614R2 <https://wg21.link/P2614R2>`__","Deprecate ``numeric_limits::has_denorm``","2023-02 (Issaquah)","|Complete|","18",""
Expand Down
29 changes: 29 additions & 0 deletions libcxx/include/__functional/reference_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@
#define _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H

#include <__compare/synth_three_way.h>
#include <__concepts/convertible_to.h>
#include <__config>
#include <__functional/weak_result_type.h>
#include <__memory/addressof.h>
#include <__type_traits/common_reference.h>
#include <__type_traits/desugars_to.h>
#include <__type_traits/enable_if.h>
#include <__type_traits/invoke.h>
#include <__type_traits/is_const.h>
#include <__type_traits/is_core_convertible.h>
#include <__type_traits/is_same.h>
#include <__type_traits/is_specialization.h>
#include <__type_traits/remove_cvref.h>
#include <__type_traits/void_t.h>
#include <__utility/declval.h>
Expand Down Expand Up @@ -156,6 +159,32 @@ template <class _CanonicalTag, class _Operation, class... _Args>
inline const bool __desugars_to_v<_CanonicalTag, reference_wrapper<_Operation>, _Args...> =
__desugars_to_v<_CanonicalTag, _Operation, _Args...>;

#if _LIBCPP_STD_VER >= 20

template <class _Tp>
inline constexpr bool __is_ref_wrapper = __is_specialization_v<_Tp, reference_wrapper>;

template <class _Rp, class _Tp, class _RpQual, class _TpQual>
concept __ref_wrap_common_reference_exists_with = __is_ref_wrapper<_Rp> && requires {
typename common_reference_t<typename _Rp::type&, _TpQual>;
} && convertible_to<_RpQual, common_reference_t<typename _Rp::type&, _TpQual>>;

template <class _Rp, class _Tp, template <class> class _RpQual, template <class> class _TpQual>
requires(__ref_wrap_common_reference_exists_with<_Rp, _Tp, _RpQual<_Rp>, _TpQual<_Tp>> &&
!__ref_wrap_common_reference_exists_with<_Tp, _Rp, _TpQual<_Tp>, _RpQual<_Rp>>)
struct basic_common_reference<_Rp, _Tp, _RpQual, _TpQual> {
using type _LIBCPP_NODEBUG = common_reference_t<typename _Rp::type&, _TpQual<_Tp>>;
};

template <class _Tp, class _Rp, template <class> class _TpQual, template <class> class _RpQual>
requires(__ref_wrap_common_reference_exists_with<_Rp, _Tp, _RpQual<_Rp>, _TpQual<_Tp>> &&
!__ref_wrap_common_reference_exists_with<_Tp, _Rp, _TpQual<_Tp>, _RpQual<_Rp>>)
struct basic_common_reference<_Tp, _Rp, _TpQual, _RpQual> {
using type _LIBCPP_NODEBUG = common_reference_t<typename _Rp::type&, _TpQual<_Tp>>;
};

#endif // _LIBCPP_STD_VER >= 20

_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H
11 changes: 8 additions & 3 deletions libcxx/include/__type_traits/common_reference.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#define _LIBCPP___TYPE_TRAITS_COMMON_REFERENCE_H

#include <__config>
#include <__type_traits/add_pointer.h>
#include <__type_traits/common_type.h>
#include <__type_traits/copy_cv.h>
#include <__type_traits/copy_cvref.h>
Expand Down Expand Up @@ -139,13 +140,17 @@ struct __common_reference_sub_bullet2 : __common_reference_sub_bullet3<_Tp, _Up>
template <class _Tp, class _Up>
struct __common_reference_sub_bullet1 : __common_reference_sub_bullet2<_Tp, _Up> {};

// sub-bullet 1 - If T1 and T2 are reference types and COMMON-REF(T1, T2) is well-formed, then
// the member typedef `type` denotes that type.
// sub-bullet 1 - Let R be COMMON-REF(T1, T2). If T1 and T2 are reference types, R is well-formed, and
// is_convertible_v<add_pointer_t<T1>, add_pointer_t<R>> && is_convertible_v<add_pointer_t<T2>, add_pointer_t<R>> is
// true, then the member typedef type denotes R.

template <class _Tp, class _Up>
struct common_reference<_Tp, _Up> : __common_reference_sub_bullet1<_Tp, _Up> {};

template <class _Tp, class _Up>
requires is_reference_v<_Tp> && is_reference_v<_Up> && requires { typename __common_ref_t<_Tp, _Up>; }
requires is_reference_v<_Tp> && is_reference_v<_Up> && requires { typename __common_ref_t<_Tp, _Up>; } &&
is_convertible_v<add_pointer_t<_Tp>, add_pointer_t<__common_ref_t<_Tp, _Up>>> &&
is_convertible_v<add_pointer_t<_Up>, add_pointer_t<__common_ref_t<_Tp, _Up>>>
struct __common_reference_sub_bullet1<_Tp, _Up> {
using type _LIBCPP_NODEBUG = __common_ref_t<_Tp, _Up>;
};
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/functional
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ POLICY: For non-variadic implementations, the number of arguments is limited
# include <__functional/bind_front.h>
# include <__functional/identity.h>
# include <__functional/ranges_operations.h>
# include <__type_traits/common_reference.h>
# include <__type_traits/unwrap_ref.h>
# endif

Expand Down
4 changes: 4 additions & 0 deletions libcxx/include/version
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ __cpp_lib_char8_t 201907L <atomic> <filesy
__cpp_lib_chrono 201611L <chrono>
__cpp_lib_chrono_udls 201304L <chrono>
__cpp_lib_clamp 201603L <algorithm>
__cpp_lib_common_reference 202302L <type_traits>
__cpp_lib_common_reference_wrapper 202302L <functional>
__cpp_lib_complex_udls 201309L <complex>
__cpp_lib_concepts 202002L <concepts>
__cpp_lib_constexpr_algorithms 202306L <algorithm> <utility>
Expand Down Expand Up @@ -402,6 +404,8 @@ __cpp_lib_void_t 201411L <type_traits>
# if _LIBCPP_HAS_CHAR8_T
# define __cpp_lib_char8_t 201907L
# endif
# define __cpp_lib_common_reference 202302L
# define __cpp_lib_common_reference_wrapper 202302L
# define __cpp_lib_concepts 202002L
# define __cpp_lib_constexpr_algorithms 201806L
# define __cpp_lib_constexpr_complex 201711L
Expand Down
4 changes: 4 additions & 0 deletions libcxx/modules/std/functional.inc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export namespace std {
using std::invoke_r;
#endif

#if _LIBCPP_STD_VER >= 20
using std::basic_common_reference;
#endif

// [refwrap], reference_wrapper
using std::reference_wrapper;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
# error "__cpp_lib_boyer_moore_searcher should not be defined before c++17"
# endif

# ifdef __cpp_lib_common_reference_wrapper
# error "__cpp_lib_common_reference_wrapper should not be defined before c++20"
# endif

# ifdef __cpp_lib_constexpr_functional
# error "__cpp_lib_constexpr_functional should not be defined before c++20"
# endif
Expand Down Expand Up @@ -94,6 +98,10 @@
# error "__cpp_lib_boyer_moore_searcher should not be defined before c++17"
# endif

# ifdef __cpp_lib_common_reference_wrapper
# error "__cpp_lib_common_reference_wrapper should not be defined before c++20"
# endif

# ifdef __cpp_lib_constexpr_functional
# error "__cpp_lib_constexpr_functional should not be defined before c++20"
# endif
Expand Down Expand Up @@ -165,6 +173,10 @@
# error "__cpp_lib_boyer_moore_searcher should have the value 201603L in c++17"
# endif

# ifdef __cpp_lib_common_reference_wrapper
# error "__cpp_lib_common_reference_wrapper should not be defined before c++20"
# endif

# ifdef __cpp_lib_constexpr_functional
# error "__cpp_lib_constexpr_functional should not be defined before c++20"
# endif
Expand Down Expand Up @@ -245,6 +257,13 @@
# error "__cpp_lib_boyer_moore_searcher should have the value 201603L in c++20"
# endif

# ifndef __cpp_lib_common_reference_wrapper
# error "__cpp_lib_common_reference_wrapper should be defined in c++20"
# endif
# if __cpp_lib_common_reference_wrapper != 202302L
# error "__cpp_lib_common_reference_wrapper should have the value 202302L in c++20"
# endif

# ifndef __cpp_lib_constexpr_functional
# error "__cpp_lib_constexpr_functional should be defined in c++20"
# endif
Expand Down Expand Up @@ -337,6 +356,13 @@
# error "__cpp_lib_boyer_moore_searcher should have the value 201603L in c++23"
# endif

# ifndef __cpp_lib_common_reference_wrapper
# error "__cpp_lib_common_reference_wrapper should be defined in c++23"
# endif
# if __cpp_lib_common_reference_wrapper != 202302L
# error "__cpp_lib_common_reference_wrapper should have the value 202302L in c++23"
# endif

# ifndef __cpp_lib_constexpr_functional
# error "__cpp_lib_constexpr_functional should be defined in c++23"
# endif
Expand Down Expand Up @@ -441,6 +467,13 @@
# error "__cpp_lib_boyer_moore_searcher should have the value 201603L in c++26"
# endif

# ifndef __cpp_lib_common_reference_wrapper
# error "__cpp_lib_common_reference_wrapper should be defined in c++26"
# endif
# if __cpp_lib_common_reference_wrapper != 202302L
# error "__cpp_lib_common_reference_wrapper should have the value 202302L in c++26"
# endif

# ifndef __cpp_lib_constexpr_functional
# error "__cpp_lib_constexpr_functional should be defined in c++26"
# endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
# error "__cpp_lib_bounded_array_traits should not be defined before c++20"
# endif

# ifdef __cpp_lib_common_reference
# error "__cpp_lib_common_reference should not be defined before c++20"
# endif

# ifdef __cpp_lib_has_unique_object_representations
# error "__cpp_lib_has_unique_object_representations should not be defined before c++17"
# endif
Expand Down Expand Up @@ -130,6 +134,10 @@
# error "__cpp_lib_bounded_array_traits should not be defined before c++20"
# endif

# ifdef __cpp_lib_common_reference
# error "__cpp_lib_common_reference should not be defined before c++20"
# endif

# ifdef __cpp_lib_has_unique_object_representations
# error "__cpp_lib_has_unique_object_representations should not be defined before c++17"
# endif
Expand Down Expand Up @@ -250,6 +258,10 @@
# error "__cpp_lib_bounded_array_traits should not be defined before c++20"
# endif

# ifdef __cpp_lib_common_reference
# error "__cpp_lib_common_reference should not be defined before c++20"
# endif

# ifndef __cpp_lib_has_unique_object_representations
# error "__cpp_lib_has_unique_object_representations should be defined in c++17"
# endif
Expand Down Expand Up @@ -394,6 +406,13 @@
# error "__cpp_lib_bounded_array_traits should have the value 201902L in c++20"
# endif

# ifndef __cpp_lib_common_reference
# error "__cpp_lib_common_reference should be defined in c++20"
# endif
# if __cpp_lib_common_reference != 202302L
# error "__cpp_lib_common_reference should have the value 202302L in c++20"
# endif

# ifndef __cpp_lib_has_unique_object_representations
# error "__cpp_lib_has_unique_object_representations should be defined in c++20"
# endif
Expand Down Expand Up @@ -568,6 +587,13 @@
# error "__cpp_lib_bounded_array_traits should have the value 201902L in c++23"
# endif

# ifndef __cpp_lib_common_reference
# error "__cpp_lib_common_reference should be defined in c++23"
# endif
# if __cpp_lib_common_reference != 202302L
# error "__cpp_lib_common_reference should have the value 202302L in c++23"
# endif

# ifndef __cpp_lib_has_unique_object_representations
# error "__cpp_lib_has_unique_object_representations should be defined in c++23"
# endif
Expand Down Expand Up @@ -763,6 +789,13 @@
# error "__cpp_lib_bounded_array_traits should have the value 201902L in c++26"
# endif

# ifndef __cpp_lib_common_reference
# error "__cpp_lib_common_reference should be defined in c++26"
# endif
# if __cpp_lib_common_reference != 202302L
# error "__cpp_lib_common_reference should have the value 202302L in c++26"
# endif

# ifndef __cpp_lib_has_unique_object_representations
# error "__cpp_lib_has_unique_object_representations should be defined in c++26"
# endif
Expand Down
Loading
Loading