On Wednesday, 6 May 2020 at 08:04:16 UTC, Jacob Carlborg wrote:
On 2020-05-05 19:11, learner wrote:
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:
Yes,
On 2020-05-05 19:11, learner wrote:
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:
Yes, kind of:
void foo(string caller = __FUNCTION__)()
{
import
On Tuesday, 5 May 2020 at 18:19:00 UTC, Meta wrote:
mixin template magic()
{
alias CallerRet = typeof(return);
CallerRet magic()
{
return CallerRet.init;
}
}
Small edit: you can remove the "CallerRet" alias by doing the
following:
mixin template magic()
{
On Tuesday, 5 May 2020 at 17:11:53 UTC, learner wrote:
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
On Tuesday, May 5, 2020 11:11:53 AM MDT learner via Digitalmars-d-learn
wrote:
> 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() {
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 =
On Tuesday, 5 May 2020 at 16:36:48 UTC, learner wrote:
I mean, without using the function name in the body, like
ReturnType!foo ?
even easier:
typeof(return)
Good morning,
Is it possible something like this?
```
int foo() {
__traits(some_trait, some_generic_this) theInt = 0;
```
I mean, without using the function name in the body, like
ReturnType!foo ?