I have this kind of code :
template <typename T1,
typename T2 = void,
typename T3 = void,
typename T4 = void,
typename T5 = void>
std::set<std::type_info const*> MyClass<T1,T2,T3,T4,T5>::get_types()
{
std::set<std::type_info const*> t;
t.push_back(&typeid(T1));
if(typeid(T2) != typeid(void))
t.push_back(&typeid(T2));
else
return;
if(typeid(T3) != typeid(void))
t.push_back(&typeid(T3));
else
return;
if(typeid(T4) != typeid(void))
t.push_back(&typeid(T4));
else
return;
if(typeid(T5) != typeid(void))
t.push_back(&typeid(T5));
else
return;
}
Is there a way to make a loop over templates types T2
to T5
to avoid redundant code ?
Note: I don't use C++11. I use boost.