lundi 24 septembre 2018

Calling a secondary template function for each variadic template parameter [duplicate]

I'm trying to do something similar to this:

template <typename ComponentType>
void AddComponent()
{
    //Create an instance of ComponentType and do stuff...
}

template <typename... MultipleComponentTypes>
void AddMultipleComponents()
{
    for(ComponentType in MultipleComponentTypes)
    {
        AddComponent<ComponentType>();
    }
}

Obviously, this is just pseudo-code to give you an idea of what I'm trying to achieve. Unlike this or this, I don't have an instance of the Component I can use as arguments for the function - is this achievable with some kind of recursion or fold expression?

Aucun commentaire:

Enregistrer un commentaire