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

### 2755. §[string.view.io] uses non-existent `basic_string_view::to_string` function

Section: 21.4.6 [string.view.io], 21.3.4.4 [string.io] Status: C++17 Submitter: Billy Baker Opened: 2016-07-26 Last modified: 2020-09-06

Priority: 0

View all issues with C++17 status.

Discussion:

In looking at N4606, [string.view.io] has an Effects clause that references `basic_string_view::to_string` which no longer exists after the application of P0254R2.

[2016-07-26, Marshall suggests concrete wording]

[2016-07 Chicago LWG]

Monday: P0 - tentatively ready

Proposed resolution:

This wording is relative to N4606.

1. Modify 21.3.4.4 [string.io] as indicated:

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

   > > -5- Effects: Equivalent to: `return os << basic_string_view<charT, traits>(str);`Behaves as a formatted output function (29.7.5.3.1 [ostream.formatted.reqmts]) of `os`. Forms a character sequence `seq`, initially consisting of the elements defined by the range `[str.begin(), str.end())`. Determines padding for `seq` as described in 29.7.5.3.1 [ostream.formatted.reqmts]. Then inserts `seq` as if by calling `os.rdbuf()->sputn(seq, n)`, where `n` is the larger of `os.width()` and `str.size()`; then calls `os.width(0)`.

   > > -6- Returns: `os`

2. Modify 21.4.6 [string.view.io] as indicated:

   >     template<class charT, class traits>
   >       basic_ostream<charT, traits>&
   >         operator<<(basic_ostream<charT, traits>& os,
   >                    basic_string_view<charT, traits> str);

   > > -1- Effects: Equivalent to: `return os << str.to_string();`Behaves as a formatted output function (29.7.5.3.1 [ostream.formatted.reqmts]) of `os`. Forms a character sequence `seq`, initially consisting of the elements defined by the range `[str.begin(), str.end())`. Determines padding for `seq` as described in 29.7.5.3.1 [ostream.formatted.reqmts]. Then inserts `seq` as if by calling `os.rdbuf()->sputn(seq, n)`, where `n` is the larger of `os.width()` and `str.size()`; then calls `os.width(0)`.

   > > -?- Returns: `os`