Unlike function declarations with parameter packs, I've found that classes require the type for each argument in the angle brackets...
Component<IntegerPair, int, int> temp(40, 5);
...which seems redundant. Here's how I defined Component
:
template<typename T, class... T_Args>
class Component
{
public:
Component(T_Args... args)
: m_data(args...)
{}
T m_data;
};
- Is there a way to remove
int, int
from the above statement? - If so, is it ok to remove it?
- Also, is my way of instantiation
m_data
safe? When usingstd::forward<T_Args>(args)...
my compiler told me I didn't have a constructor that could convert all of the argument types.