M
Marcin Kalicinski
Hi,
I am modernizing a small library that is being currently in use by some
people. In the new version I want to forbid use of a template function with
argument of const char * (i.e. I want to get compile errors when it
happens). For the rest of the types function should work ok.
// A template function, in old version of the library allowed for all types
template<typename T> void func(T t)
{
/* ... */
}
Now I want to forbid its use with const char *. For example I could use
specialization in the following way:
template<> void func(const char *)
{
const int a = 0;
a = 1;
}
Is there a cleaner way of achieving the same? Expecially to get better error
message? (ideally the error message should say that func(const char*) is
undefined).
Best regards,
Marcin
I am modernizing a small library that is being currently in use by some
people. In the new version I want to forbid use of a template function with
argument of const char * (i.e. I want to get compile errors when it
happens). For the rest of the types function should work ok.
// A template function, in old version of the library allowed for all types
template<typename T> void func(T t)
{
/* ... */
}
Now I want to forbid its use with const char *. For example I could use
specialization in the following way:
template<> void func(const char *)
{
const int a = 0;
a = 1;
}
Is there a cleaner way of achieving the same? Expecially to get better error
message? (ideally the error message should say that func(const char*) is
undefined).
Best regards,
Marcin