I have this source code which allows me to cast a Point<float>
to Point<double>
:
template<class T> struct Point{
template <typename NewType> Point<NewType> cast() const{
return Point<NewType>();
}
};
int main(){
Point<float> p1;
Point<double> p2;
p2 = p1.cast<double>();
return 0;
}
This source code compiles well. Now, I add the following class and I have a compilation error at the line that does the cast:
template <class T> struct PointContainer{
void test(){
Point<T> p1;
Point<double> p2;
p2 = p1.cast<double>(); //compilation error
}
};
Compilation error: error: expected primary-expression before ‘double’
.
Why do I get this error and how can I solve it?