Похожие чаты

Uint64_t combine_squares(Square square = 0) { return square; } template<typename

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.

4 ответов

38 просмотров

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

Hayk-Zneigras Автор вопроса
Manav | avoid unnecessary messaging me
Ah refactoring variadic templates to something cle...

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

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта