The following example is working when I manualy replace T wirh char *, but why is not working as it is:
T
char *
template
Try converting to const T&. Also, in these cases, you should let the compiler automatically deduce the template argument, and not specify it.