esrille / escudo

The Escudo Web Browser
Apache License 2.0
68 stars 13 forks source link

Convert stream to boolean explicitly #27

Closed Constellation closed 11 years ago

Constellation commented 11 years ago

(U16TrivialInputStream::operator bool): Replace with istream::good call (U16TrivialInputStream::operator!): Replace with istream::good call

operator bool is libstdc++ extension. So libc++ doesn't have this feature.

edit: Changed issue title to "Convert stream to boolean explicitly" See comment

ShikiOkasaka commented 11 years ago

operator bool is libstdc++ extension. So libc++ doesn't have this feature.

Is this correct? I don't have a copy of the final ISO C++11 specification, but in 27.5.5 in n3247 these are defined as,

explicit operator bool() const;
bool operator!() const;

cf. http://en.cppreference.com/w/cpp/io/basic_ios/operator_bool

Anyway, if the current code is not compatible with libc++, I'm fine to fix these.

Constellation commented 11 years ago

Is this correct?

Ah, sorry! I've checked n3337 (final draft of C++11) and found explicit operator bool definition. Thanks for your pointing. And I saw libc++ defines explicit operator bool. I misunderstood reasons of this compile error.

Because of explicit of explicit operator bool, clang++ rejects implicit boolean conversion return stream;. So we should write return bool(stream); instead of return stream;

I'll rebase this soon. Thanks for your awesome review comment :)

ShikiOkasaka commented 11 years ago

:+1:

Because of explicit of explicit operator bool, clang++ rejects implicit boolean conversion return stream;. So we should write return bool(stream); instead of return stream;

I see. Thanks for the description!

ShikiOkasaka commented 11 years ago

Merged at a479327c4b730430f5a5bc3bc7e8cec0724b86f9