I have a problem with inner classes in class templates. I have a template class (say:) Matrix<T>and a subclass (say:) Matrix<T>::Row. Now I want to write a function that works with instances of a subclass (say:) negate(Matrix<T>::Row &). I tried to declare a function using template<class T> negate(typename Matrix<T>::Row &), but when I try to use it, the compiler tells me that it cannot find a match.
Here is an abstract example:
template<class T>
class A
{
public:
class B
{
};
};
template<class T>
void x(typename A<T>::B &)
{
}
int main()
{
A<int>::B b;
x(b);
x<int>(b);
}
Why can't the compiler find xin the first case? Is there a way to change this so that it works (without explicitly specifying a type int)?
( , x template<class T, class S> void x(typename A<T>::B &, const S &);, , .)
g++ 4.4.3, g++ 4.5.2 Sun Studio 5.9, . - !