Date: Sun, 26 Oct 2025 19:52:47 +0000
Hi there Muhammad,
What you're looking for is already possible in the reflection capabilities added in C++26 - you can return a std::meta::info which represents the reflection of a type and splice it to use that type.
To rewrite one of your examples:
consteval auto select_type(int n) {
return n == 0 ? ^^int : ^^double;
}
Which can then be accessed in non-reflection code via
using T = [: select_type(1) :];
And this is just the tip of the iceberg in terms of what is possible with reflection and rewriting template patterns into something which more resembles typical C++ code.
Does this about cover what you were wanting to make possible, or is there some extra layer to it which I've missed?
What you're looking for is already possible in the reflection capabilities added in C++26 - you can return a std::meta::info which represents the reflection of a type and splice it to use that type.
To rewrite one of your examples:
consteval auto select_type(int n) {
return n == 0 ? ^^int : ^^double;
}
Which can then be accessed in non-reflection code via
using T = [: select_type(1) :];
And this is just the tip of the iceberg in terms of what is possible with reflection and rewriting template patterns into something which more resembles typical C++ code.
Does this about cover what you were wanting to make possible, or is there some extra layer to it which I've missed?
Received on 2025-10-26 19:52:51
