Is the expression [: select_type(1) :] allowed any where a type is expected (for instance as a default value for template parameter). If so then yes this is what I was proposing.

------ Original Message ------
From "Matthew Taylor" <mjtaylor214@hotmail.com>
To "std-proposals@lists.isocpp.org" <std-proposals@lists.isocpp.org>
Cc "Muhammad" <mail@muhamad.me>
Date 10/26/2025 10:52:47 PM
Subject Re: [std-proposals] consteval typename auto - type-returning immediate functions

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?