Reputation: 4577
The following code
template<typename T, typename U> class Alpha
{
public:
template<typename V> void foo() {}
};
template<typename T, typename U> class Beta
{
public:
Alpha<T, U> alpha;
void arf();
};
template<typename T, typename U> void Beta<T, U>::arf()
{
alpha.foo<int>();
}
int main()
{
Beta<int, float> beta;
beta.arf();
return 0;
}
Fails to compile due to:
../src/main.cpp: In member function ‘void Beta::arf()’:
../src/main.cpp:16: error: expected primary-expression before ‘int’
../src/main.cpp:16: error: expected ‘;’ before ‘int’
How the heck do I fix this? I've tried everything I can think of.
Upvotes: 2
Views: 109
Reputation: 98984
alpha::foo
is a dependent name, use alpha.template foo<int>()
.
Dependent names are assumed to
typename
template
Upvotes: 4
Reputation: 56956
Try alpha.template foo<int>()
. Note that your code compiles fine with VC8. Since alpha is of dependant type, you have to specify that foo is a template.
Upvotes: 4