]> gcc.gnu.org Git - gcc.git/commit
libstdc++: Update std::pointer_traits to match new LWG 3545 wording
authorJonathan Wakely <jwakely@redhat.com>
Mon, 26 Sep 2022 17:59:45 +0000 (18:59 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Mon, 18 Mar 2024 13:50:55 +0000 (13:50 +0000)
commit57eb0358d0e0925f9e5aa282ed7f0274f6ff794e
treea5b533844defae159adec31ec9d983aa9a7860fc
parent1bb467f4910dc4abd90a7be98653b63113e5d6d3
libstdc++: Update std::pointer_traits to match new LWG 3545 wording

It was pointed out in recent LWG 3545 discussion that having a
constrained partial specialization of std::pointer_traits can cause
ambiguities with program-defined specializations. For example, the
addition to the testcase has:

template<typename P> requires std::derived_from<P, base_type
struct std::pointer_traits<P>;

This would be ambiguous with the library's own constrained partial
specialization:

template<typename Ptr> requires requires { typename Ptr::element_type; }
struct std::pointer_traits<Ptr>;

Neither specialization is more specialized than the other for a type
that is derived from base_type and also has an element_type member.

The solution is to remove the library's partial specialization, and do
the check for Ptr::element_type in the __ptr_traits_elem helper (which
is what we already do for !__cpp_concepts anyway).

libstdc++-v3/ChangeLog:

* include/bits/ptr_traits.h (__ptr_traits_elem) [__cpp_concepts]:
Also define the __ptr_traits_elem class template for the
concepts case.
(pointer_traits<Ptr>): Remove constrained partial
specialization.
* testsuite/20_util/pointer_traits/lwg3545.cc: Check for
ambiguitiy with program-defined partial specialization.

(cherry picked from commit 03cb9ed8dd603dbb77762ca948fc6381ba190731)
libstdc++-v3/include/bits/ptr_traits.h
libstdc++-v3/testsuite/20_util/pointer_traits/lwg3545.cc
This page took 0.056924 seconds and 6 git commands to generate.