[gcc r16-5009] libstdc++: add ADL friends
Jason Merrill
jason@gcc.gnu.org
Mon Nov 3 18:32:59 GMT 2025
https://gcc.gnu.org/g:5926cc99ae18eb9cc5d0081c4b0e90f87c7d31e6
commit r16-5009-g5926cc99ae18eb9cc5d0081c4b0e90f87c7d31e6
Author: Jason Merrill <jason@redhat.com>
Date: Sat Nov 1 16:07:18 2025 +0300
libstdc++: add ADL friends
Since the implementation namespaces __detail and __exception_ptr aren't
exported from std, ADL can't find these functions there. Adding friend
declarations makes it work.
libstdc++-v3/ChangeLog:
* include/bits/quoted_string.h: Add ADL friends.
* libsupc++/exception_ptr.h: Add ADL friend.
Diff:
---
libstdc++-v3/include/bits/quoted_string.h | 23 +++++++++++++++++++++++
libstdc++-v3/libsupc++/exception_ptr.h | 4 ++++
2 files changed, 27 insertions(+)
diff --git a/libstdc++-v3/include/bits/quoted_string.h b/libstdc++-v3/include/bits/quoted_string.h
index 3a828d5eab94..9a51aa367fe5 100644
--- a/libstdc++-v3/include/bits/quoted_string.h
+++ b/libstdc++-v3/include/bits/quoted_string.h
@@ -61,6 +61,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_Quoted_string&
operator=(_Quoted_string&) = delete;
+ // Friends for ADL with module std.
+ template<typename _CharT2, typename _Traits>
+ friend std::basic_ostream<_CharT2, _Traits>&
+ operator<<(std::basic_ostream<_CharT2, _Traits>& __os,
+ const _Quoted_string<const _CharT2*, _CharT2>& __str);
+
+ template<typename _CharT2, typename _Traits, typename _String2>
+ friend std::basic_ostream<_CharT2, _Traits>&
+ operator<<(std::basic_ostream<_CharT2, _Traits>& __os,
+ const _Quoted_string<_String2, _CharT2>& __str);
+
+ template<typename _CharT2, typename _Traits, typename _Alloc>
+ friend std::basic_istream<_CharT2, _Traits>&
+ operator>>(std::basic_istream<_CharT2, _Traits>& __is,
+ const _Quoted_string<basic_string<_CharT2, _Traits, _Alloc>&,
+ _CharT2>& __str);
+
_String _M_string;
_CharT _M_delim;
_CharT _M_escape;
@@ -78,6 +95,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_Quoted_string&
operator=(_Quoted_string&) = delete;
+ // Friend for ADL with module std.
+ template<typename _CharT2, typename _Traits2, typename _String2>
+ friend std::basic_ostream<_CharT2, _Traits2>&
+ operator<<(std::basic_ostream<_CharT2, _Traits2>& __os,
+ const _Quoted_string<_String2, _CharT2>& __str);
+
basic_string_view<_CharT, _Traits> _M_string;
_CharT _M_delim;
_CharT _M_escape;
diff --git a/libstdc++-v3/libsupc++/exception_ptr.h b/libstdc++-v3/libsupc++/exception_ptr.h
index f673a3343338..76482db37565 100644
--- a/libstdc++-v3/libsupc++/exception_ptr.h
+++ b/libstdc++-v3/libsupc++/exception_ptr.h
@@ -214,6 +214,10 @@ namespace std _GLIBCXX_VISIBILITY(default)
{ return __x._M_exception_object != __y._M_exception_object; }
#endif
+ // Friend for ADL with module std.
+ friend _GLIBCXX26_CONSTEXPR void
+ swap(exception_ptr& __lhs, exception_ptr& __rhs);
+
const class std::type_info*
__cxa_exception_type() const _GLIBCXX_USE_NOEXCEPT
__attribute__ ((__pure__));
More information about the Libstdc++-cvs
mailing list