Eof - to return or to throw?

Dawid Ciężarkiewicz dawid.ciezarkiewicz at asn.pl
Tue Feb 13 06:32:35 PST 2007


Andrei Alexandrescu (See Website For Email) wrote:

> All you have to do is:
> 
> try {
> auto amount = ThrowEof(io.readWithReturningEof(buf));
> useData(buf, amount);
> } catch (Eof e) {
> /* do smth */
> }
> 
> ThrowEof is an identity function (see? the identity function I discussed
> a while ago wasn't that silly...) that returns whatever goes through it,
> not before checking for -1 and throwing if that's the case.

That is a nice. I'll have to use that in my code.



More information about the Digitalmars-d mailing list