mardi 23 janvier 2018

c++ variadic template into AND statement

I am trying use a variadic template in an && statement, but i dont know how to actually do it. Can somebody explain to me how i can programm a function like this one:

using EntitySet = std::vector<Entity>;
template<typename... TArgs>
EntitySet getEntitesWith()
{
    EntitySet entitySet;
    for(const Entity& entity : m_entitySet)
    {
        if (entity.hasComponent<T1>() && entity.hasComponent<T2>() && ...)
        {
            entitySet.push_back(entity);
        }
    }
    return entitySet;
}

entity.hasComponent<>() returns true if the entity has a Component of the type that is passed into the function

Aucun commentaire:

Enregistrer un commentaire