diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2022-12-09 14:59:01 +0000 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2022-12-12 14:00:08 +0000 |
commit | 2327d9331430777006008ab3b051afe2b4fc15bd (patch) | |
tree | a7e971828ddabbaf548a236f89b9567024ab7b06 | |
parent | 14d0f82cab37b66e2998b8d0d664711bd1e1371b (diff) | |
download | gcc-2327d9331430777006008ab3b051afe2b4fc15bd.zip gcc-2327d9331430777006008ab3b051afe2b4fc15bd.tar.gz gcc-2327d9331430777006008ab3b051afe2b4fc15bd.tar.bz2 |
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:
-rw-r--r-- | libstdc++-v3/include/std/stacktrace | 38 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/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 ec3335e..83c6463 100644 --- a/libstdc++-v3/include/std/stacktrace +++ b/libstdc++-v3/include/std/stacktrace @@ -165,9 +165,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return __state; } - template<typename _CharT, typename _Traits> - 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<typename _CharT, typename _Traits> - 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<typename _CharT, typename _Traits, typename _Allocator> - inline basic_ostream<_CharT, _Traits>& - operator<<(basic_ostream<_CharT, _Traits>& __os, - const basic_stacktrace<_Allocator>& __st) + template<typename _Allocator> + 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 72582fa..262abea 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<class Allocator> string to_string(const basic_stacktrace<Allocator>& st); - template<class charT, class traits> - basic_ostream<charT, traits>& - operator<<(basic_ostream<charT, traits>& os, const stacktrace_entry& f); + ostream& + operator<<(ostream& os, const stacktrace_entry& f); - template<class charT, class traits, class Allocator> - basic_ostream<charT, traits>& - operator<<(basic_ostream<charT, traits>& os, const basic_stacktrace<Allocator>& st); + template<class Allocator> + ostream& + operator<<(ostream& os, const basic_stacktrace<Allocator>& st); namespace pmr { using stacktrace = basic_stacktrace<polymorphic_allocator<stacktrace_entry>>; |