[Bug libstdc++/67399] no match for istream::operator==
daniel.kruegler at googlemail dot com
gcc-bugzilla@gcc.gnu.org
Mon Aug 31 19:48:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67399
Daniel Krügler <daniel.kruegler at googlemail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |daniel.kruegler@googlemail.
| |com
--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
In C++ there never existed an operator== for istream. The reason, why your code
compiles in C++03 is because std::basic_ios had
operator void*() const;
which was considered in this context to compare void* against a null pointer
literal. This implicit conversion of iostream could lead to very subtle and
surprising valid expression. When C++11 became standardized the language had
introduced *explicit* conversion functions and the above member became replaced
by
explicit operator bool() const;
which doesn't support your kind of conversion example anymore. If you want to
write code that works in all currently existing C++ versions, you should better
replace
if (cin.getline(x, sizeof (x)) == 0) { .. }
by
if (!cin.getline(x, sizeof (x))) { .. }
In other words: This is an invalid bug report.
More information about the Gcc-bugs
mailing list