From: Jonathan Wakely Date: Fri, 9 Dec 2022 14:59:01 +0000 (+0000) Subject: libstdc++: Make operator<< for stacktraces less templated (LWG 3515) X-Git-Tag: basepoints/gcc-14~2596 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2327d9331430777006008ab3b051afe2b4fc15bd;p=thirdparty%2Fgcc.git libstdc++: Make operator<< for stacktraces less templated (LWG 3515) This change was approved for C++23 last month. libstdc++-v3/ChangeLog: * include/std/stacktrace (operator<<): Only output to narrow ostreams (LWG 3515). * testsuite/19_diagnostics/stacktrace/synopsis.cc: --- diff --git a/libstdc++-v3/include/std/stacktrace b/libstdc++-v3/include/std/stacktrace index ec3335e89d81..83c6463b0d8b 100644 --- a/libstdc++-v3/include/std/stacktrace +++ b/libstdc++-v3/include/std/stacktrace @@ -165,9 +165,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return __state; } - template - friend basic_ostream<_CharT, _Traits>& - operator<<(basic_ostream<_CharT, _Traits>&, const stacktrace_entry&); + friend ostream& + operator<<(ostream&, const stacktrace_entry&); bool _M_get_info(string* __desc, string* __file, int* __line) const @@ -720,25 +719,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION noexcept(noexcept(__a.swap(__b))) { __a.swap(__b); } - template - inline basic_ostream<_CharT, _Traits>& - operator<<(basic_ostream<_CharT, _Traits>& __os, - const stacktrace_entry& __f) - { - string __desc, __file; - int __line; - if (__f._M_get_info(&__desc, &__file, &__line)) - { - __os.width(4); - __os << __desc << " at " << __file << ':' << __line; - } - return __os; - } + inline ostream& + operator<<(ostream& __os, const stacktrace_entry& __f) + { + string __desc, __file; + int __line; + if (__f._M_get_info(&__desc, &__file, &__line)) + { + __os.width(4); + __os << __desc << " at " << __file << ':' << __line; + } + return __os; + } - template - inline basic_ostream<_CharT, _Traits>& - operator<<(basic_ostream<_CharT, _Traits>& __os, - const basic_stacktrace<_Allocator>& __st) + template + inline ostream& + operator<<(ostream& __os, const basic_stacktrace<_Allocator>& __st) { for (stacktrace::size_type __i = 0; __i < __st.size(); ++__i) { diff --git a/libstdc++-v3/testsuite/19_diagnostics/stacktrace/synopsis.cc b/libstdc++-v3/testsuite/19_diagnostics/stacktrace/synopsis.cc index 72582fa53c6a..262abea21ecf 100644 --- a/libstdc++-v3/testsuite/19_diagnostics/stacktrace/synopsis.cc +++ b/libstdc++-v3/testsuite/19_diagnostics/stacktrace/synopsis.cc @@ -28,13 +28,12 @@ namespace std template string to_string(const basic_stacktrace& st); - template - basic_ostream& - operator<<(basic_ostream& os, const stacktrace_entry& f); + ostream& + operator<<(ostream& os, const stacktrace_entry& f); - template - basic_ostream& - operator<<(basic_ostream& os, const basic_stacktrace& st); + template + ostream& + operator<<(ostream& os, const basic_stacktrace& st); namespace pmr { using stacktrace = basic_stacktrace>;