Retrieve the return type of the current function

learner learner at nomail.com
Tue May 5 17:11:53 UTC 2020


On Tuesday, 5 May 2020 at 16:41:06 UTC, Adam D. Ruppe wrote:

> typeof(return)

Thank you, that was indeed easy!

Is it possible to retrieve also the caller return type? Something 
like:

```
int foo() {
     return magic();
}

auto magic(maybesomedefaulttemplateargs = ??)() {
     alias R = __traits(???); // --> int!
}
```

Mixin templates maybe?


More information about the Digitalmars-d-learn mailing list