This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of LEWG status.

### 3515. §[stacktrace.basic.nonmem]: `operator<<` should be less templatized

Section: 20.21.2 [stacktrace.syn], 20.21.4.6 [stacktrace.basic.nonmem] Status: LEWG Submitter: Jiang An Opened: 2021-01-25 Last modified: 2021-03-12

Priority: 2

View other active issues in [stacktrace.syn].

View all other issues in [stacktrace.syn].

View all issues with LEWG status.

Discussion:

According to 21.3.4.4 [string.io], the `operator<<` overloads in 20.21.4.6 [stacktrace.basic.nonmem] are well-formed only if the template parameters `charT` and `traits` are `char` and `std::char_traits<char>` (that of `std::string`) respectively, because it is required in Effects: that these overloads behave as-if insert a `std::string`.

I think the declarations of these overloads should be changed to:

>     ostream& operator<<(ostream& os, const stacktrace_entry& f);

>     template<class Allocator>
>     ostream& operator<<(ostream& os, const basic_stacktrace<Allocator>& st);

[2021-03-12; Reflector poll]

Set priority to 2 and status to LEWG following reflector poll.

Proposed resolution:

This wording is relative to N4878.

1. Modify 20.21.2 [stacktrace.syn], header `<stacktrace>` synopsis, as indicated:

   >     namespace std {
   >       // 20.21.3 [stacktrace.entry], class stacktrace_entry
   >       class stacktrace_entry;

   >       // 20.21.4 [stacktrace.basic], class template basic_stacktrace
   >       template<class Allocator>
   >       class basic_stacktrace;

   >       […]

   >       // 20.21.4.6 [stacktrace.basic.nonmem], non-member functions
   >       […]

   >       string to_string(const stacktrace_entry& f);

   >       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);

   >       template<class charT, class traits, class Allocator>
   >         basic_ostream<charT, traits>&
   >           operator<<(basic_ostream<charT, traits>& os, const basic_stacktrace<Allocator>& st);

   >       […]
   >     }

2. Modify 20.21.4.6 [stacktrace.basic.nonmem] as indicated:

   >     template<class charT, class traits>
   >     basic_ostream<charT, traits>&
   >       operator<<(basic_ostream<charT, traits>& os, const stacktrace_entry& f);

   > > -4- Effects: Equivalent to: `return os << to_string(f);`

   >     template<class charT, class traits, class Allocator>
   >     basic_ostream<charT, traits>&
   >       operator<<(basic_ostream<charT, traits>& os, const basic_stacktrace<Allocator>& st);

   > > -5- Effects: Equivalent to: `return os << to_string(st);`