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

Section: 19.6.2 [stacktrace.syn], 19.6.4.6 [stacktrace.basic.nonmem] Status: C++23 Submitter: Jiang An Opened: 2021-01-25 Last modified: 2023-11-22

Priority: 2

View all other issues in [stacktrace.syn].

View all issues with C++23 status.

Discussion:

According to 27.4.4.4 [string.io], the operator<< overloads in 19.6.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.

[2022-11-07; Kona]

Move to Immediate.

[2022-11-12 Approved at November 2022 meeting in Kona. Status changed: Immediate → WP.]

Proposed resolution:

This wording is relative to N4878.

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

    namespace std {
      // 19.6.3 [stacktrace.entry], class stacktrace_entry
      class stacktrace_entry;
      
      // 19.6.4 [stacktrace.basic], class template basic_stacktrace
      template<class Allocator>
      class basic_stacktrace;
      
      […]
      
      // 19.6.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 19.6.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);