N
Nephi Immortal
I already explicitly defined X< 1 > x since argument explicitly exists. I do not want to tell the Compiler to deduce the template argument in Test() function, but it should be done implicitly.
error C2783: 'void Test(const X<T>::Y &)' : could not deduce template argument for 'T'
template< int T >
class X
{
private:
class Y
{
public:
Y() {}
~Y() {}
void Do() const {}
};
template< int T >
friend void Test( typename const X< T >::Y& ref );
public:
X() {}
~X() {}
Y Go() { return Y(); }
};
template< int T >
void Test( typename const X< T >::Y& ref )
{
ref.Do();
}
int main()
{
X< 1 > x;
Test< 1 >( x.Go() ); // OK
// Test( x.Go() ); // error C2783: 'void Test(const X<T>::Y &)' : could not deduce template argument for 'T'
return 0;
}
error C2783: 'void Test(const X<T>::Y &)' : could not deduce template argument for 'T'
template< int T >
class X
{
private:
class Y
{
public:
Y() {}
~Y() {}
void Do() const {}
};
template< int T >
friend void Test( typename const X< T >::Y& ref );
public:
X() {}
~X() {}
Y Go() { return Y(); }
};
template< int T >
void Test( typename const X< T >::Y& ref )
{
ref.Do();
}
int main()
{
X< 1 > x;
Test< 1 >( x.Go() ); // OK
// Test( x.Go() ); // error C2783: 'void Test(const X<T>::Y &)' : could not deduce template argument for 'T'
return 0;
}