c++ - [bug report] built-in operator == overloading
- Christof Meerwald (27/27) Jul 15 2004 struct A {
 
struct A {
    A( bool b )
        : b_( b )
    { }
    operator int () {
        return b_ ? 0 : 1;
    }
    operator bool () {
        return b_;
    }
    bool b_;
};
int main() {
    A a( true );;
    // see 13.6 Built-in operators
    // operator == only exists for promoted arithmetic types
    if( a == true ) return 1;
// Error: ambiguous type conversion
    if( a == 1 ) return 1;
// Error: ambiguous type conversion
    return 0;
}
bye, Christof
-- 
http://cmeerw.org                                 JID: cmeerw jabber.at
mailto cmeerw at web.de
...and what have you contributed to the Net?
 Jul 15 2004








 
 
 
 Christof Meerwald <cmeerw web.de>