
2007/10/12, John Maddock <john@johnmaddock.co.uk>:
Simon Atanasyan wrote:
Bad news - all other version of Sun C++ have a bug. Compiler cannot deduce a type of template parameter for the template specialization based on function return type. Here is test case for this bug:
A possible workaround is to add unused argument that helps compiler to handle template specialization: Following code works good:
template <class T> T f(T* = 0) { return T(); }
template <> float f(float*) { return 1.0; }
int main() { f<float>(); }
So this is the same issue for which we define BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS and associated workarounds?
Probably yes.
If so which versions of __SUNPRO_CC should we define it for?
Unfortunately __SUNPRO_CC denotes version of compiler without patch number. This bug has been fixed since Sun C++ 5.9 patch-01. But it exists in the Sun C++ 5.9. In both cases __SUNPRO_CC is equal to 0x590.
Strangely the config tests don't pick this up: the test case is libs/config/test/boost_no_exp_func_tem_arg.ipp BTW.
boost_no_exp_func_tem_arg.ipp does not contain specialization of function template where template argument is used as a return value type only. So Sun C++ compiles this code without error. -- Simon Atanasyan