mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:17:34 +00:00
Streams: Consistent behaviour when reading from stream with error.
The streaming operator doesn't short-circuit, consider the following snippet: void foo(InputStream& stream) { int a, b; stream >> a >> b; } If the first read fails, the second is called regardless. It should be well defined what happens in this case: nothing.
This commit is contained in:
parent
5d85be7ed4
commit
6de63782c7
8 changed files with 24 additions and 3 deletions
|
@ -40,8 +40,10 @@ public:
|
|||
|
||||
size_t read(Bytes bytes) override
|
||||
{
|
||||
size_t nread = 0;
|
||||
if (has_any_error())
|
||||
return 0;
|
||||
|
||||
size_t nread = 0;
|
||||
if (bytes.size() >= 1) {
|
||||
if (m_next_byte.has_value()) {
|
||||
bytes[0] = m_next_byte.value();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue