Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LWG-3515: [stacktrace.basic.nonmem]: operator<< should be less templatized #3236

Merged
merged 2 commits into from
Nov 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions stl/inc/stacktrace
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,12 @@ _NODISCARD string to_string(const basic_stacktrace<_Alloc>& _St) {
return _Result;
}

_EXPORT_STD template <class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& _Os, const stacktrace_entry& _Fx) {
_EXPORT_STD ostream& operator<<(ostream& _Os, const stacktrace_entry& _Fx) {
return _Os << _STD to_string(_Fx);
}

_EXPORT_STD template <class _CharT, class _Traits, class _Alloc>
basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& _Os, const basic_stacktrace<_Alloc>& _St) {
_EXPORT_STD template <class _Alloc>
ostream& operator<<(ostream& _Os, const basic_stacktrace<_Alloc>& _St) {
return _Os << _STD to_string(_St);
}

Expand Down
1 change: 1 addition & 0 deletions tests/std/test.lst
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ tests\LWG3146_excessive_unwrapping_ref_cref
tests\LWG3234_math_special_overloads
tests\LWG3422_seed_seq_ctors
tests\LWG3480_directory_iterator_range
tests\LWG3515_stacktrace_ostream_operator_should_be_less_templatized
tests\LWG3610_iota_view_size_and_integer_class
tests\P0019R8_atomic_ref
tests\P0024R2_parallel_algorithms_adjacent_difference
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

RUNALL_INCLUDE ..\usual_latest_matrix.lst
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <concepts>
#include <memory>
#include <memory_resource>
#include <ostream>
#include <sstream>
#include <stacktrace>
#include <string>

using namespace std;

template <class Ostream, class Alloc = allocator<stacktrace_entry>>
concept CanPrintStacktrace = requires(Ostream& os, const stacktrace_entry& f, const basic_stacktrace<Alloc>& st) {
os << f;
os << st;
};

template <class CharT>
struct FancyCharTraits : char_traits<CharT> {};

static_assert(CanPrintStacktrace<ostream>);
static_assert(CanPrintStacktrace<ostringstream>);
static_assert(CanPrintStacktrace<ostream, pmr::polymorphic_allocator<stacktrace_entry>>);

static_assert(!CanPrintStacktrace<wostream>);
static_assert(!CanPrintStacktrace<wostringstream>);
static_assert(!CanPrintStacktrace<wostream, pmr::polymorphic_allocator<stacktrace_entry>>);

using FancyCharStream = basic_ostream<char, FancyCharTraits<char>>;
static_assert(!CanPrintStacktrace<FancyCharStream>);
static_assert(!CanPrintStacktrace<FancyCharStream, pmr::polymorphic_allocator<stacktrace_entry>>);

using FancyWcharStream = basic_ostream<wchar_t, FancyCharTraits<wchar_t>>;
static_assert(!CanPrintStacktrace<FancyWcharStream>);
static_assert(!CanPrintStacktrace<FancyWcharStream, pmr::polymorphic_allocator<stacktrace_entry>>);

int main() {} // COMPILE-ONLY