خرید بک لینک

Vote count: 0

I have an EntityComponent-System and there's one component which should call functions on various other components. For this example here I've chosen a simple combination of the results of a boolean function.

The ResultCombinerComponent has variadic template arguments and for each of these arguments it should call a function, in the order that the template arguments are given. The order is very important.

Afterwards the results of the function calls are combined.

In the code below I just replaced the parts that I don't know how to achieve with psuedo-C++

template<typename... Args>
class ResultCombinerComponent
{
    template<typename T> 
    bool calcSingleResult()
    {
        retu getComponent<T>()->calcResult();
    }

    bool calcResult()
    {
        bool result = true;
        for (int i = 0; i < sizeof...(Args); i++)  // doesn't work
        {
            if (!calcSingleResult<Args(i)>()  // doesn't work
            {
                result = false;
                break;
            }
        }
        retu result;
    }

}

asked 3 mins ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 11 ارديبهشت 1395 ساعت: 19:28

صفحه بندی