C++ Logo

std-proposals

Advanced search

Re: [std-proposals] [Draft] Typed and Safer Stream API for C++

From: Jonathan Wakely <cxx_at_[hidden]>
Date: Sun, 7 Sep 2025 11:55:46 +0100
For the record, Jerome replied off-list repeating the incorrect claim that
this doesn't work, and when I repeated that he misunderstands the API, he
replied *again* claiming that you can't read from an ifstream opened with
ios::out. Because he didn't bother to read what I wrote (twice) nor bother
to read the standard reference I provided.

I've now provided a working example to prove that his claim is wrong:
https://godbolt.org/z/zjd4oYh3h

I'll see where that goes, but I'm starting to wonder if he is just trolling
this list.



On Sat, 6 Sept 2025, 22:23 Jonathan Wakely, <cxx_at_[hidden]> wrote:

>
>
> On Sat, 6 Sept 2025 at 12:06, Jerome Saint-Martin via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>> *Problem*
>> The current ifstream/ofstream API allows illogical mode combinations:
>> std::ifstream f("data.txt", std::ios::out); // Compiles, but doesn't
>> work
>>
> What doesn't work here?
>
> The filebuf is opened with mode ios::out|ios::in and so reading from the
> ifstream works fine.
>
> See https://eel.is/c++draft/ifstream.cons#2.sentence-1
>

Received on 2025-09-07 10:56:06