I have the following cpp code:
#include <iostream> #include <limits> // C2589 when compiling with specialization, fine when compiling without template<typename T> void foo(T value = std::numeric_limits<T>::infinity() ) { } // this specialization causes compiler error C2589 above template<> void foo<float>( float value ) { } int main() { foo<float>(); return 0; }
When I try to compile this using Visual Studio 2013, I get the following error:
..\check2\main.cpp(5) : error C2589: '::' : illegal token on right side of '::' ..\check2\main.cpp(5) : error C2059: syntax error : '::'
The program compiles fine if I do not include the foo<float> specialization. The code also compiles fine , including specialization under gcc 4.8.4, which indicates some problems with the Visual C ++ compiler.
Is the code correct and should it compile? Is there a workaround for Visual C ++?
source share