A
atai
A question on C++:
Is the following legal C++ code?
typedef int (*func)(int);
template <class A>
class D1
{
public:
template <class B>
func f(void)
{
return A::some_func<B>;
}
};
template <class A1, class B1>
func g(void)
{
return A1::m1<B1>;
}
g++ (4.4.1) would not compile this code, with error
/tmp/t.cpp: In member function ‘int (* D1<A>::f())(int)’:
/tmp/t.cpp:12: error: expected primary-expression before ‘>’ token
/tmp/t.cpp:12: error: expected primary-expression before ‘;’ token
/tmp/t.cpp: In function ‘int (* g())(int)’:
/tmp/t.cpp:20: error: expected primary-expression before ‘>’ token
/tmp/t.cpp:20: error: expected primary-expression before ‘;’ token
but it seems to be something that should be legal.
Thanks for any answer on this
Is the following legal C++ code?
typedef int (*func)(int);
template <class A>
class D1
{
public:
template <class B>
func f(void)
{
return A::some_func<B>;
}
};
template <class A1, class B1>
func g(void)
{
return A1::m1<B1>;
}
g++ (4.4.1) would not compile this code, with error
/tmp/t.cpp: In member function ‘int (* D1<A>::f())(int)’:
/tmp/t.cpp:12: error: expected primary-expression before ‘>’ token
/tmp/t.cpp:12: error: expected primary-expression before ‘;’ token
/tmp/t.cpp: In function ‘int (* g())(int)’:
/tmp/t.cpp:20: error: expected primary-expression before ‘>’ token
/tmp/t.cpp:20: error: expected primary-expression before ‘;’ token
but it seems to be something that should be legal.
Thanks for any answer on this