?
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
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
probably the cleanest way of doing that is with a macro
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.
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.
Обсуждают сегодня