Search code examples
c++templatesvariadic-templates

C++ template packed parameters


I'm wondering how I can specify a template type as "parameter pack".

The commented line doesn't work because it can't deduce T (it has the same template parameters). On the next line I can fix that by supplying T but I'm stuck at how I should supply the parameter pack type (where the question marks are.).

template<typename T, typename... Args> T& Entity::addComponent(Args&&... args) const
{
    //return entityManager->addComponent(std::forward<Args>(args)...);
    return entityManager->addComponent<T, ?????>(std::forward<Args>(args)...);
}

I want to use Args as that type.


Solution

  • It worked when I set Visual studio "Conformance Mode" setting to "No"