Ok so consider this code :
namespace Bar
{
template <class T2>
T2 f()
{
return T2(0);
}
}
template <class T>
void Foo(float y = Bar::f<float>())
{
}
int main()
{
Foo<int>(); // C2783: 'T2 Bar::f(void)' : could not deduce template
argument for 'T2'
return 0;
}
It does not compile with Visual C++ 2005 and 2008, but G++ has no
problem with it.
But now, if I remove the template from Foo, it works :
namespace Bar
{
template <class T2>
T2 f()
{
return T2(0);
}
};
void Foo(float y = Bar::f<float>())
{
}
int main()
{
Foo<int>(); // no problem
return 0;
}
And if f is not in a namespace, it works too :
template <class T2>
T2 f()
{
return T2(0);
}
template <class T>
void Foo(float y = f<float>())
{
}
int main()
{
Foo<int>(); // no problem
return 0;
}
Any idea ? Thank you.
--
[ See http://www.gotw.ca/resources/clcm.htm
for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]