Похожие чаты

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 ответов

12 просмотров

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.

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

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

Всем привет! Имеется функция: function IsValidChar(ch: UTF8Char): Boolean; var i: Integer; ValidChars: AnsiString; begin ValidChars := 'abcdefghijklmnopqrstuvwxyzABCDE...
Евгений
44
For all those that keep asking why no pump? why this ? and why that...? Please close ur ewt chart and open 2 others - TOTAL (total mc) and BTC.D (btc dominance). Maybe BTC a...
Inn3r_G
19
"Since pnut can flip FTM easily, I'm swapping my FTM to pnut and hoping for a easy x5-x10" Perfect recipe for disaster. NFA but chances are, you'll end up as exit liquidity ...
C. A.
7
AMD status update? No longer in the plan but something might be around the corner later on Chinese partner? No longer in the plan. This market does not seem to be the top ...
Ben
6
Добрый день, подскажите, пожалуйста, по проблеме. Сегодня на работе утром обнаружилось что по рдп подключиться не получается к серверу 2022. В серверную зашел - на системно...
srv
19
Ready for some fun AND a chance to win TKO Tokens? Join us for exciting minigames in our Telegram group! 🕒 Don’t miss out—games start on today 25 October 2024, at 8 PM! Ge...
Milkyway | Tokocrypto
255
Чтобы перехватить все нажимания буков на форме, надо хук ставить? Пробовал на форме ОнКейДаун, оно ловит клаву если фокус не на компоненте с вводом текста
Serjone
15
лучше скажите, причём тут паскаль?
Alexey Kulakov
36
Hey Why do I need headers files in c++ code when creating non library program? does it possible to import namespace without headers?
Jacob
12
Всем привет! вывожу на общей стр дочерние ресурсыв каждом ресурсе галерея, и первая фотка должна выводиться на общей [!DocLister? &prepare=photo !]
Alekso
12
Карта сайта