public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/ranger] libstdc++: Fix <ext/pointer.h> incompatibilities with C++20
@ 2020-06-17 17:47 Aldy Hernandez
0 siblings, 0 replies; only message in thread
From: Aldy Hernandez @ 2020-06-17 17:47 UTC (permalink / raw)
To: gcc-cvs, libstdc++-cvs
https://gcc.gnu.org/g:1a7886386cea722d0d7b61730b4d1dd6d9a19109
commit 1a7886386cea722d0d7b61730b4d1dd6d9a19109
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Jan 9 21:31:55 2020 +0000
libstdc++: Fix <ext/pointer.h> incompatibilities with C++20
The equality operators for _ExtPtr_allocator are defined as non-const
member functions, which causes ambiguities in C++20 due to the
synthesized operator!= candidates. They should always have been const.
The _Pointer_adapter class template has both value_type and element_type
members, which makes readable_traits<_Pointer_adapter<T>> ambiguous. The
intended workaround is to add a specialization of readable_traits.
* include/ext/extptr_allocator.h (_ExtPtr_allocator::operator==)
(_ExtPtr_allocator::operator!=): Add missing const qualifiers.
* include/ext/pointer.h (readable_traits<_Pointer_adapter<S>>): Add
partial specialization to disambiguate the two constrained
specializations.
From-SVN: r280067
Diff:
---
libstdc++-v3/ChangeLog | 6 ++++++
libstdc++-v3/include/ext/extptr_allocator.h | 8 ++++----
libstdc++-v3/include/ext/pointer.h | 11 +++++++++++
3 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 721b465b369..65cd480ddcc 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,11 @@
2020-01-09 Jonathan Wakely <jwakely@redhat.com>
+ * include/ext/extptr_allocator.h (_ExtPtr_allocator::operator==)
+ (_ExtPtr_allocator::operator!=): Add missing const qualifiers.
+ * include/ext/pointer.h (readable_traits<_Pointer_adapter<S>>): Add
+ partial specialization to disambiguate the two constrained
+ specializations.
+
* include/experimental/type_traits (experimental::is_pod_v): Disable
-Wdeprecated-declarations warnings around reference to std::is_pod.
* include/std/type_traits (is_pod_v): Likewise.
diff --git a/libstdc++-v3/include/ext/extptr_allocator.h b/libstdc++-v3/include/ext/extptr_allocator.h
index 933bdb69a51..88090548b7c 100644
--- a/libstdc++-v3/include/ext/extptr_allocator.h
+++ b/libstdc++-v3/include/ext/extptr_allocator.h
@@ -131,20 +131,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Up>
inline bool
- operator==(const _ExtPtr_allocator<_Up>& __rarg)
+ operator==(const _ExtPtr_allocator<_Up>& __rarg) const
{ return _M_real_alloc == __rarg._M_getUnderlyingImp(); }
inline bool
- operator==(const _ExtPtr_allocator& __rarg)
+ operator==(const _ExtPtr_allocator& __rarg) const
{ return _M_real_alloc == __rarg._M_real_alloc; }
template<typename _Up>
inline bool
- operator!=(const _ExtPtr_allocator<_Up>& __rarg)
+ operator!=(const _ExtPtr_allocator<_Up>& __rarg) const
{ return _M_real_alloc != __rarg._M_getUnderlyingImp(); }
inline bool
- operator!=(const _ExtPtr_allocator& __rarg)
+ operator!=(const _ExtPtr_allocator& __rarg) const
{ return _M_real_alloc != __rarg._M_real_alloc; }
template<typename _Up>
diff --git a/libstdc++-v3/include/ext/pointer.h b/libstdc++-v3/include/ext/pointer.h
index 84d530054e6..02d3e60169f 100644
--- a/libstdc++-v3/include/ext/pointer.h
+++ b/libstdc++-v3/include/ext/pointer.h
@@ -46,6 +46,9 @@
# include <bits/move.h>
# include <bits/ptr_traits.h>
#endif
+#if __cplusplus > 201703L
+# include <iterator> // for readable_traits
+#endif
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
@@ -594,6 +597,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ return pointer(std::addressof(__r)); }
};
+#if __cpp_lib_concepts
+ template<typename _Storage_policy>
+ struct readable_traits<__gnu_cxx::_Pointer_adapter<_Storage_policy>>
+ {
+ using value_type
+ = typename __gnu_cxx::_Pointer_adapter<_Storage_policy>::value_type;
+ };
+#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-06-17 17:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-17 17:47 [gcc/devel/ranger] libstdc++: Fix <ext/pointer.h> incompatibilities with C++20 Aldy Hernandez
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).