42 comme unsigned int est bien défini comme "42U".
unsigned int foo = 42U; // yeah!
Comment puis-je écrire "23" de sorte qu'il est clair qu'il est un unsigned short int?
unsigned short bar = 23; // booh! not clear!
MODIFIER de sorte que le sens de la question est plus claire:
template <class T>
void doSomething(T) {
std::cout << "unknown type" << std::endl;
}
template<>
void doSomething(unsigned int) {
std::cout << "unsigned int" << std::endl;
}
template<>
void doSomething(unsigned short) {
std::cout << "unsigned short" << std::endl;
}
int main(int argc, char* argv[])
{
doSomething(42U);
doSomething((unsigned short)23); // no other option than a cast?
return EXIT_SUCCESS;
}