From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 95A05385514B; Mon, 12 Dec 2022 14:00:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 95A05385514B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1670853650; bh=wQwF/ucEVgDYJjJ9d13Hm0LZnxCJl9W+RtuxZqvmIZM=; h=From:To:Subject:Date:From; b=ZSw/IiLKMb8TPIMphacxZKfVfRW3fX2nHkE94xSWjoCgRf3imZD9SPNBQUAG1yKKz ghcbmzaVA8avMcjfUa38Vr82gwK6zzWrSh+i3NGdzpSs1008ZLEpDHj5FogArVq2IW mXeiHGZxf9CoUy4AeVUKq2JvGmCX71tw88JZexgo= 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 r13-4611] libstdc++: Make operator<< for stacktraces less templated (LWG 3515) X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: 14d0f82cab37b66e2998b8d0d664711bd1e1371b X-Git-Newrev: 2327d9331430777006008ab3b051afe2b4fc15bd Message-Id: <20221212140050.95A05385514B@sourceware.org> Date: Mon, 12 Dec 2022 14:00:50 +0000 (GMT) List-Id: https://gcc.gnu.org/g:2327d9331430777006008ab3b051afe2b4fc15bd commit r13-4611-g2327d9331430777006008ab3b051afe2b4fc15bd 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: 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 ec3335e89d8..83c6463b0d8 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 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>;