First, typename ... Squares>
uint64_t combine_squares(First first, Squares ... rest)
{
combine_squares(rest...);
}
Hi. In order to get my function work I had to implement that first function. But it looks ugly, because it doesn't make sense with a single variable. Also if I pass two variables but let them have default values still it will be ugly because it will serve no purpose other than allowing the second function to work. This is my first time with variadic templates. Are there any other ways to do this? Note that I've simplified the second function, it actually does something more I just emphasized the part that interests me.
Ah refactoring variadic templates to something clean while still keeping it performant and the binary size in check is a pain, the no of recursions and the compile time can quickly go out of hand for more than 4-5 parameters with different type. There is a way to compress variadic templates but that uses returning as an initializer list. Also C++ 17 gives you four fold expressions which can be helpful. Please send your actual code, especially the implementation of what uint64_t combine_squares(Square square); does.
and the reason why first, and rest of the combine_squares need to be seperated
Thanks. There I call a comvine_squares to combine first and combine_squares(rest...) that's why I considered the option of creating a function with two arguments each with default values. And finaly I return the result of combine_squares with two arguments. What it does is that it generates uint64_t values from each argument and return their bitwise or. Sorry that I'm not sharing the code now, I'm in university, but I think the other time I asked a question there was that code too. Let me check
Обсуждают сегодня