Suppose that you want to write a C++ that prints a series of values, but also their type.
E.g., given
print_all(1.2, "abc", 3, std::vector<int>({2,3}));
You want...
double = 1.2
const char* = abc
int = 3
std::vector<int> = [2, 3]
You can do it in C++26 with little code.
1. Use 'templattime iteration.
2. Call display_string_of on the reflection of the types. (Don't forget the rabbit ears ^^)
E.g., given
print_all(1.2, "abc", 3, std::vector<int>({2,3}));
You want...
double = 1.2
const char* = abc
int = 3
std::vector<int> = [2, 3]
You can do it in C++26 with little code.
1. Use 'templattime iteration.
2. Call display_string_of on the reflection of the types. (Don't forget the rabbit ears ^^)
Aug 18, 2026 · 1:49 PM UTC
22
12
154
11,316
@lemire specialize `std::formatter<std::meta::info>` please I want to write:
`std::println("{}"sv, ^^int);`
`std::println("{}"sv, ^^int);`
0
0
4
278
@lemire You can do this in D with even less code, and a lot nicer. And we have been enjoying these abilities for years already.
1
0
2
392
@lemire isn't this a bit "cheating"? you took everything by value, "abc" is const char[4], the others are prvalues too, but handy reflection indeed
1
0
1
578
@lemire Something about reading C++ code that makes my heart tingle
0
0
0
73
@lemire Make scoped namespacing cool again. Not everyone has developed "std::*" goggles, nor should they.
2
0
0
458
@lemire Lo bueno es que sale de reflection nativa, imprimes el tipo sin macros ni RTTI y te funciona con cualquier tipo propio.
0
0
0
385

























