Template function specialization default argument?

There is nothing wrong with the code; Comeau Online, Intel C++ 11.1, and g++ 4.1.2 compile it successfully I would guess that it is a bug in the compiler. I recently submitted a related, but slightly different bug report against the Visual C++ 2010 compiler As a workaround, you can wrap the calls: template T get_limits_min() { return std::numeric_limits::min(); } template T get_limits_max() { return std::numeric_limits::max(); } template void function(T arg1, T min = get_limits_min(), T max = get_limits_max()) { } Ugly? Quite I posted the following in response to the bug you reported on Microsoft Connect: The primary template must have a parameter that has a default argument value.

The default argument value must be a member function of a class template not in the global namespace The following is minimal code to reproduce: namespace N { template struct S { static T g() { return T(); } }; } template void f(T = N::S::g()) { } template void f(int) { } int main() { f(); } The compiler emits the following errors, both on the line where the primary template is defined: error C2589: '::' : illegal token on right side of '::' error C2059: syntax error : ':: Interestingly, there is another issue if the class template is in the global namespace. Given the following code: template struct S { static T g() { return T(); } }; template void f(T = ::S::g()) { } template void f(int) { } int main() { f(); } The compiler emits the following error on the line on which the primary template is defined: error C2064: term does not evaluate to a function taking 0 arguments Both of these example test cases are well-formed C++ programs.

There is nothing wrong with the code; Comeau Online, Intel C++ 11.1, and g++ 4.1.2 compile it successfully. I would guess that it is a bug in the compiler. I recently submitted a related, but slightly different bug report against the Visual C++ 2010 compiler.As a workaround, you can wrap the calls: template T get_limits_min() { return std::numeric_limits::min(); } template T get_limits_max() { return std::numeric_limits::max(); } template void function(T arg1, T min = get_limits_min(), T max = get_limits_max()) { } Ugly?

Quite. I posted the following in response to the bug you reported on Microsoft Connect: The primary template must have a parameter that has a default argument value. The default argument value must be a member function of a class template not in the global namespace.

The following is minimal code to reproduce: namespace N { template struct S { static T g() { return T(); } }; } template void f(T = N::S::g()) { } template void f(int) { } int main() { f(); } The compiler emits the following errors, both on the line where the primary template is defined: error C2589: '::' : illegal token on right side of '::' error C2059: syntax error : '::' Interestingly, there is another issue if the class template is in the global namespace. Given the following code: template struct S { static T g() { return T(); } }; template void f(T = ::S::g()) { } template void f(int) { } int main() { f(); } The compiler emits the following error on the line on which the primary template is defined: error C2064: term does not evaluate to a function taking 0 arguments Both of these example test cases are well-formed C++ programs.

– uray Aug 4 '10 at 3:31 @uray: You can submit it at connect.microsoft. Com via that bug report link I listed; you'll have to com/VisualStudio/feedback/details/583081 – uray Aug 4 '10 at 3:42.

It is succeesfully compiled... in Comeau Online ,codepad.org,EDG Compiler ,and G++ .

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions