Q:

C++ Template specification for both const and regular type

I want to make a single template specification that will work for all form like:
char*, const char*, char* const

etc...
How do I do this with the C++ syntax?
Thank you.

A:

You don't really need templates if you want to write a function which works with all three versions and does the same. Here is a sample program to demonstrate this:
void f(const char* const c)
{
}

int main()
{
  char ch='h';
  char*c=&ch;
  const char*cc="hi";
  char* const cc1=&ch;
  f(c);
  f(cc);
  f(cc1);
}

It compiles fine with g++4.7.

