mirror of git://gcc.gnu.org/git/gcc.git
libstdc++: Implement P2655R3 changes to common_reference bullet 1
We implement this paper as a DR against C++20 (as do MSVC and libc++). PR libstdc++/120446 libstdc++-v3/ChangeLog: * include/bits/version.def (common_reference): New. * include/bits/version.h: Regenerate. * include/std/type_traits (__glibcxx_want_common_reference): Define. (__common_reference_impl<T1, T2, 1>): Add pointer convertibility constraints as per P2655R3. * testsuite/20_util/common_reference/p2655r3.cc: New test. Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com> Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
This commit is contained in:
parent
cbdbbdd1fc
commit
a9fd651fbb
|
|
@ -1821,6 +1821,14 @@ ftms = {
|
|||
};
|
||||
};
|
||||
|
||||
ftms = {
|
||||
name = common_reference;
|
||||
values = {
|
||||
v = 202302;
|
||||
cxxmin = 20; // We treat P2655R3 as a DR against C++20.
|
||||
};
|
||||
};
|
||||
|
||||
ftms = {
|
||||
name = formatters;
|
||||
values = {
|
||||
|
|
|
|||
|
|
@ -2030,6 +2030,16 @@
|
|||
#endif /* !defined(__cpp_lib_flat_set) */
|
||||
#undef __glibcxx_want_flat_set
|
||||
|
||||
#if !defined(__cpp_lib_common_reference)
|
||||
# if (__cplusplus >= 202002L)
|
||||
# define __glibcxx_common_reference 202302L
|
||||
# if defined(__glibcxx_want_all) || defined(__glibcxx_want_common_reference)
|
||||
# define __cpp_lib_common_reference 202302L
|
||||
# endif
|
||||
# endif
|
||||
#endif /* !defined(__cpp_lib_common_reference) && defined(__glibcxx_want_common_reference) */
|
||||
#undef __glibcxx_want_common_reference
|
||||
|
||||
#if !defined(__cpp_lib_formatters)
|
||||
# if (__cplusplus >= 202100L) && _GLIBCXX_HOSTED
|
||||
# define __glibcxx_formatters 202302L
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
#define __glibcxx_want_bool_constant
|
||||
#define __glibcxx_want_bounded_array_traits
|
||||
#define __glibcxx_want_common_reference
|
||||
#define __glibcxx_want_constant_wrapper
|
||||
#define __glibcxx_want_has_unique_object_representations
|
||||
#define __glibcxx_want_integral_constant_callable
|
||||
|
|
@ -4240,6 +4241,12 @@ template<typename _Ret, typename _Fn, typename... _Args>
|
|||
template<typename _Tp1, typename _Tp2>
|
||||
requires is_reference_v<_Tp1> && is_reference_v<_Tp2>
|
||||
&& requires { typename __common_ref<_Tp1, _Tp2>; }
|
||||
#if __cpp_lib_common_reference // C++ >= 20
|
||||
&& is_convertible_v<add_pointer_t<_Tp1>,
|
||||
add_pointer_t<__common_ref<_Tp1, _Tp2>>>
|
||||
&& is_convertible_v<add_pointer_t<_Tp2>,
|
||||
add_pointer_t<__common_ref<_Tp1, _Tp2>>>
|
||||
#endif
|
||||
struct __common_reference_impl<_Tp1, _Tp2, 1>
|
||||
{ using type = __common_ref<_Tp1, _Tp2>; };
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
// P2655R3 - common_reference_t of reference_wrapper Should Be a Reference Type
|
||||
// Implemented as a DR against C++20
|
||||
// { dg-do compile { target c++20 } }
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#if __cpp_lib_common_reference != 202302L
|
||||
# error "Feature-test macro __cpp_lib_common_reference has wrong value in <type_traits>"
|
||||
#endif
|
||||
|
||||
struct A { };
|
||||
struct B { operator A&() const; };
|
||||
|
||||
static_assert( std::is_same_v<std::common_reference_t<A&, const B&>, A&> );
|
||||
static_assert( std::is_same_v<std::common_reference_t<const B&, A&>, A&> );
|
||||
Loading…
Reference in New Issue