[cfe-dev] clang c++0x template function declaration error

Toralf Niebuhr mamuelle at niebuhrt.de
Mon Jul 4 08:44:50 PDT 2011


Hey,


I am trying to get the following code to compile and I am not sure
wether this is my mistake or a compiler bug:

--------------------------------- test.cpp
template <class T, void (T::*foo)() > class X { };

template <class T> 
auto type_constructor( void (T::*f)() ) -> X< T, f >;


class Y
{
   public:
       void bar() {};
};

int main () {
   decltype( type_constructor( &Y::bar ) ) x;
}
---------------------------------

It fails with the following message, which doesn't explain what went
wrong:

$ clang++ -c test.cpp -std=c++0x

test.cpp:14:15: error: no matching function for call to
'type_constructor' decltype( type_constructor( &Y::bar ) ) x;
             ^~~~~~~~~~~~~~~~
test.cpp:4:6: note: candidate template ignored: substitution failure
[with T = Y] auto type_constructor( void (T::*f)() ) -> X< T, f >;
    ^
test.cpp:14:45: error: C++ requires a type specifier for all
declarations decltype( type_constructor( &Y::bar ) ) x;
   ~~~~~~~~                                ^
2 errors generated.


Can I give you more information?



More information about the cfe-dev mailing list