RFC: why do our std::ofsteam functions add ios_base::trunc ?

Jonathan Wakely jwakely@redhat.com
Mon Oct 30 15:36:00 GMT 2017


On 24/10/17 19:25 +0100, Jonathan Wakely wrote:
>While adding the new C++17 overloads taking filesystem paths to
><fstream> I noticed that ofstream uses out|trunc for the default
>arguments instead of out as the stadnard says. The effect is the same,
>but my preference would be to do what the standard says. Is there a
>good reason for deviating from what the standard says?
>
>Although the out|trunc default arguments have no difference in
>behaviour from just using out, the comments saying
>
> "Calls @c std::basic_filebuf::open(__s,__mode|out|trunc)"
>
>are definitely wrong. That would not be a conforming behaviour.
>
>Also, I think we can remove the comments saying to use c_str() as
>fstreams accept std::string arguments since C++11.
>
>Any comments?

I've removed these redundant bits from the default arguments, and from
the misleading comments.

Tested powerpc64le-linux, committed to trunk.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 6206 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20171030/59603f43/attachment.bin>


More information about the Libstdc++ mailing list