Specialization of template function after point of use will break the compilation
-
29-10-2019 - |
Question
Consider next example :
#include <iostream>
template< int a >
void foo();
int main(int argn, char* argv[])
{
foo<1>();
}
template<>
void foo<1>()
{
std::cout<<1<<std::endl;
}
The compilation fails with next error messages :
rg.cpp:12: error: specialization of ‘void foo() [with int a = 1]’ after instantiation
What paragraph in the standard explains this error?
PS :I know that if I move the function definition in front of main will make the error go away.
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow