Get return type of a template function without instantiating it
Meta via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Nov 22 05:51:05 PST 2016
On Tuesday, 22 November 2016 at 12:21:18 UTC, Yuxuan Shui wrote:
> Is there a way to get a template function return type with
> instantiating it? The return type is independent of the
> template arguments.
>
> I'm asking because there's potentially recursive template
> instantiation if I do try to instantiate it.
What you want cannot work in the general case. The template
function must be instantiated.
T identity(T)(T t)
{
return t;
}
It's not possible to calculate the type of the return value of
`identity` until it is instantiated with a type.
More information about the Digitalmars-d-learn
mailing list