Похожие чаты

Is there any way to print like this using loops

?
The sizeof(char) is : 1 bytes
The sizeof(short) is : 2 bytes
The sizeof(int) is : 4 bytes
The sizeof(long) is : 8 bytes
The sizeof(long long) is : 8 bytes
The sizeof(float) is : 4 bytes
The sizeof(double) is : 8 bytes
The sizeof(long double) is : 16 bytes
The sizeof(bool) is : 1 bytes

5 ответов

14 просмотров

I don't think there's a way to iterate over types using loops, you can use variadic templates, but they are really limited, maybe some variadic macros can do that (or combination of variadic mactos and variadic templates), but the solution will probably be super ugly. Here's an example of using variadic templates, note that string representation of the type is compiler-specific (different compilers can print different things) https://wandbox.org/permlink/rkRVPf9y1ywaDHKa

Pavel
I don't think there's a way to iterate over types ...

probably the cleanest way of doing that is with a macro

Nomid Íkorni-Sciurus Lomysz
probably the cleanest way of doing that is with a ...

i doubt it would be of any cleaner, you'll have to define recursive macros which will be more cumbersome then just doing straight up print statements with the different types.

Pavel
I don't think there's a way to iterate over types ...

Using the Boost.TypeIndex: www.boost.org/doc/libs/1_78_0/doc/html/boost_typeindex/examples.html with the variadic function could be good.

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

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

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
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
Карта сайта