C++ Logo

std-proposals

Advanced search

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

From: Jonathan Wakely <cxx_at_[hidden]>
Date: Sat, 6 Sep 2025 22:23:50 +0100
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-06 21:24:07