I saw some code like this:
template<unsigned N, unsigned M>
bool compare (const char (&p1)[N], const char (&p2)[M])
{
std::cout << "size : " << N << " " << M << std::endl;
return strcmp(p1, p2);
}
The template does not take typename
or class
as parameters, but using unsigned
, what is the usage of using nontype parameter of template?
In which case we should write template using non type parameter?