C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Readncount Proposal

From: Thiago Macieira <thiago_at_[hidden]>
Date: Wed, 17 Sep 2025 17:25:50 -0700
On Wednesday, 17 September 2025 12:26:20 Pacific Daylight Time Jonathan Wakely
via Std-Proposals wrote:
> 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?"

istream should be able to have short reads when not enough data is available,
but hasn't reached EOF (no more data will ever be available). Imagine a simple
in-process pipe where an istream is tied to an ostream: if you try to read
more than what the ostream has written, you won't get everything. But that is
not an error.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel Platform & System Engineering

Received on 2025-09-18 00:25:53