D
Dave Johansen
What is the syntax for doing an explicit specialization of a char []?
When I do an explicit specialization on "const char *" or "char *", it
doesn't handle an inline declared character array and calls the
default template method.
I'm using Visual C++ Express 2008 and below is an example of what I'm
trying to do.
Thanks,
Dave
#include <iostream>
template<typename T>
void func(const T &value)
{
std::cout << "T: " << value << std::endl;
}
template<>
void func<const char *>(const char * const &value)
{
std::cout << "CCS: ";
if (value != NULL)
std::cout << value << std::endl;
else
std::cout << "NULL" << std::endl;
}
int main(int argc, char *argv[])
{
const char *str1 = "testing1";
const char str2[] = "testing2";
func(str1);
func(str2);
return 0;
}
When I do an explicit specialization on "const char *" or "char *", it
doesn't handle an inline declared character array and calls the
default template method.
I'm using Visual C++ Express 2008 and below is an example of what I'm
trying to do.
Thanks,
Dave
#include <iostream>
template<typename T>
void func(const T &value)
{
std::cout << "T: " << value << std::endl;
}
template<>
void func<const char *>(const char * const &value)
{
std::cout << "CCS: ";
if (value != NULL)
std::cout << value << std::endl;
else
std::cout << "NULL" << std::endl;
}
int main(int argc, char *argv[])
{
const char *str1 = "testing1";
const char str2[] = "testing2";
func(str1);
func(str2);
return 0;
}