templates and casting operators
        Posted  
        
            by Jonathan Swinney
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Jonathan Swinney
        
        
        
        Published on 2010-04-19T21:27:51Z
        Indexed on 
            2010/04/19
            21:43 UTC
        
        
        Read the original article
        Hit count: 332
        
This code compiles in CodeGear 2009 and Visual Studio 2010 but not gcc. Why?
class Foo
{
public:
    operator int() const;
    template <typename T> T get() const { return this->operator T(); }
};
Foo::operator int() const
{
    return 5;
}
The error message is:
test.cpp: In member function `T Foo::get() const':
test.cpp:6: error: 'const class Foo' has no member named 'operator T'
© Stack Overflow or respective owner