compilation error with named operator

Kai Henning kai_henning@web.de
Thu Jul 28 12:19:00 GMT 2011


Hi folks,

this code compiles fine with VC and Comeau Online, but fail with GCC in every version 4.x on Windows and linux.
Can anyone explain why.

error message from GCC: 'struct FOO' has no member named 'operator FOO2<T>::type'

struct FOO
{
    operator int() const            { return static_cast< int >(7); }
    operator double() const         { return static_cast< double >(7); }
};

template < typename T >
struct FOO2
{
    typedef T       type;
    operator type() const           { return t->operator type(); }
private:
    FOO* t;
};

int main()
{
    FOO2< int > foo2; foo2.operator int();
    return 1;
}


Kai

___________________________________________________________
Schon gehört? WEB.DE hat einen genialen Phishing-Filter in die
Toolbar eingebaut! http://produkte.web.de/go/toolbar



More information about the Gcc-help mailing list