C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Readncount Proposal

From: Jonathan Wakely <cxx_at_[hidden]>
Date: Wed, 17 Sep 2025 20:30:57 +0100
On Wed, 17 Sept 2025, 20:26 Jonathan Wakely, <cxx_at_[hidden]> wrote:

>
>
> On Wed, 17 Sept 2025, 19:57 Jan Schultke via Std-Proposals, <
> std-proposals_at_[hidden]> wrote:
>
>> I don't see any major issue with the idea, but going through all these
>> standardization steps is a very big hammer for what seems to be the
>> very small problem of having to call gcount() after an I/O operation
>> separately.
>>
>
> You don't have to call gcount though. istream::read always reads the full
> count, unless it encounters EOF or an error. So generally you want to check
> "was this successful?" and not "how many characters did it read, and was
> that equal to the number I asked for?"
>
> Returning the stream allows you to check for fail it
>

* failbit

or badbit, which tells you whether the requested number of characters was
> read.
>

Received on 2025-09-17 19:31:16