I have created a type list. I then create a class using a template passing the type list. When I call the print function of the class with a some types not specified they ar
You would have to make your print function into a template and then check whether the types match:
template
void print(const U & u)
{
// use std::is_same::type, typename std::decay::type>::value
}
Here I'm stealing is_same and decay from , but if you don't have C++11, you can either take them from TR1 or from Boost, or just write them yourself, as they're very simple type modifier classes.
The conditional would best go into a static_assert, which is another C++11 feature, but there exist similar constructions for C++98/03 that produce a compile-time error under a certain condition.