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.
basic_string_view::to_string
functionSection: 27.3.5 [string.view.io], 27.4.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.
Modify 27.4.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 (31.7.6.3.1 [ostream.formatted.reqmts]) ofos
. Forms a character sequenceseq
, initially consisting of the elements defined by the range[str.begin(), str.end())
. Determines padding forseq
as described in 31.7.6.3.1 [ostream.formatted.reqmts]. Then insertsseq
as if by callingos.rdbuf()->sputn(seq, n)
, wheren
is the larger ofos.width()
andstr.size()
; then callsos.width(0)
.-6- Returns:os
Modify 27.3.5 [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:
-?- Returns:Equivalent to:Behaves as a formatted output function (31.7.6.3.1 [ostream.formatted.reqmts]) ofreturn os << str.to_string();
os
. Forms a character sequenceseq
, initially consisting of the elements defined by the range[str.begin(), str.end())
. Determines padding forseq
as described in 31.7.6.3.1 [ostream.formatted.reqmts]. Then insertsseq
as if by callingos.rdbuf()->sputn(seq, n)
, wheren
is the larger ofos.width()
andstr.size()
; then callsos.width(0)
.os