[Bug c++/38064] [c++0x] operator== doesn't work for enum classes
rbuergel at web dot de
gcc-bugzilla@gcc.gnu.org
Sun Nov 9 04:23:00 GMT 2008
------- Comment #2 from rbuergel at web dot de 2008-11-09 04:22 -------
ok, even for the case i misunderstood the proposal: there are still some
problems with it, making it unuseable.
enum class E { elem };
inline bool operator== (E c1, E c2)
{
return (int) c1 == (int) c2;
}
int main()
{
E::elem == E::elem; //works now
static_assert(E::elem == E::elem, ""); //fails
return 1;
}
tc2.cpp: In function 'int main()':
tc2.cpp:10: error: calls to overloaded operators cannot appear in a
constant-expression
... which leads to the conclusion, that strongly-typed enums can't be used in
constant-expression. That's definitely not intended by the proposal.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38064
More information about the Gcc-bugs
mailing list