diff --git a/stl/inc/stacktrace b/stl/inc/stacktrace index 0c9e184c73..69e12dd240 100644 --- a/stl/inc/stacktrace +++ b/stl/inc/stacktrace @@ -339,13 +339,13 @@ _NODISCARD string to_string(const basic_stacktrace<_Alloc>& _St) { return _Result; } -_EXPORT_STD template -basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& _Os, const stacktrace_entry& _Fx) { +_EXPORT_STD template +ostream& operator<<(ostream& _Os, const stacktrace_entry& _Fx) { return _Os << _STD to_string(_Fx); } -_EXPORT_STD template -basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& _Os, const basic_stacktrace<_Alloc>& _St) { +_EXPORT_STD template +ostream& operator<<(ostream& _Os, const basic_stacktrace<_Alloc>& _St) { return _Os << _STD to_string(_St); } diff --git a/tests/std/tests/P0881R7_stacktrace/test.cpp b/tests/std/tests/P0881R7_stacktrace/test.cpp index 74e67bf330..b726bb7dad 100644 --- a/tests/std/tests/P0881R7_stacktrace/test.cpp +++ b/tests/std/tests/P0881R7_stacktrace/test.cpp @@ -2,9 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include +#include #include #include #include +#include +#include #include #include #include @@ -20,6 +23,34 @@ using namespace std; +#if defined(__cpp_lib_concepts) // TRANSITION, GH-395 +template > +concept CanPrintStacktrace = + requires(Ostream& os, const stacktrace_entry& f, const basic_stacktrace& st) { + { os << f } -> same_as&>; + { os << st } -> same_as&>; + }; + +template +struct FancyCharTraits : char_traits {}; + +static_assert(CanPrintStacktrace); +static_assert(CanPrintStacktrace); +static_assert(CanPrintStacktrace>); + +static_assert(!CanPrintStacktrace); +static_assert(!CanPrintStacktrace); +static_assert(!CanPrintStacktrace>); + +using FancyCharStream = basic_ostream>; +static_assert(!CanPrintStacktrace); +static_assert(!CanPrintStacktrace>); + +using FancyWcharStream = basic_ostream>; +static_assert(!CanPrintStacktrace); +static_assert(!CanPrintStacktrace>); +#endif // defined(__cpp_lib_concepts) + [[maybe_unused]] const int base_line = __LINE__; // Note: the below assumes that tail call optimization is disabled, which is the case in /Od