template<typename T> void printf_t(const T&, char='\n');
template<>  void  printf_t(const  int&,     char);
void (*pi)(const int&,  char) = printf_t<int>;
int main()
{
     int a;
     scanf("%d", &a);
     pi(a);
     return 0;
}
How can I make this code work ? I want to have char argument default value in this template<int> specialization, but compiler says there is too few arguments to call function pi (it expects char). Also following code gives error:
template<typename T> void printf_t(const T&, char);
template<>  void  printf_t(const  int&,     char='\n');
void (*pi)(const int&,  char) = printf_t<int>;
int main()
{
     int a;
     scanf("%d", &a);
     pi(a);
     return 0;
}
Error:
g++     template.cpp   -o template
template.cpp:55:54: error: default argument specified in explicit specialization [-fpermissive]
55 | template<>  void  printf_t(const  int&,     char='\n');
  |
Of course I have defined printf_t<int>, but it's body is irrelevant now.
 
     
    