From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 32029388B694; Tue, 28 Mar 2023 23:35:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 32029388B694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1680046526; bh=5FujiKYFsgcb+c9WqbVG8QzBqdwmW8H+A1QGfF7n0Tc=; h=From:To:Subject:Date:From; b=rAsujDfjANA+WjDkbfWkKTrZfmE7dgCvLJSbNoCzSn05DzidJ1jOeIRl85yYGsbdI ovaQyLbXFNJuo3gtim6NBGm/ZerNCpLWKmxkAUNWrfiNMni9zDJMzTc2wf0N5qXtHn abCPmpsp8xJv3yl5MJ0PIY38yawn+Vh2IB0+EfTs= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-9348] libstdc++: Make operator<< for stacktraces less templated (LWG 3515) X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/releases/gcc-12 X-Git-Oldrev: a0955eb049901481f1fa7ebabb2ba13d58a0eac3 X-Git-Newrev: f6c6df050a3e04744f81a471a53864ee2291ef4a Message-Id: <20230328233526.32029388B694@sourceware.org> Date: Tue, 28 Mar 2023 23:35:26 +0000 (GMT) List-Id: https://gcc.gnu.org/g:f6c6df050a3e04744f81a471a53864ee2291ef4a commit r12-9348-gf6c6df050a3e04744f81a471a53864ee2291ef4a Author: Jonathan Wakely Date: Fri Dec 9 14:59:01 2022 +0000 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: (cherry picked from commit 2327d9331430777006008ab3b051afe2b4fc15bd) Diff: --- libstdc++-v3/include/std/stacktrace | 38 ++++++++++------------ .../19_diagnostics/stacktrace/synopsis.cc | 11 +++---- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/libstdc++-v3/include/std/stacktrace b/libstdc++-v3/include/std/stacktrace index a067d629a16..a7fee8531f7 100644 --- a/libstdc++-v3/include/std/stacktrace +++ b/libstdc++-v3/include/std/stacktrace @@ -160,9 +160,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 @@ -713,25 +712,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 72582fa53c6..262abea21ec 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>;