Get the return type of the function

xtreak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Feb 3 18:02:18 PST 2016


On Wednesday, 3 February 2016 at 19:21:06 UTC, Meta wrote:
> On Wednesday, 3 February 2016 at 18:40:27 UTC, xtreak wrote:
>> Thanks. I was trying to get the return type of lambdas. I was 
>> trying the following and got an error. I was using dpaste with 
>> dmd 2.070
>>
>> writeln(ReturnType!(a =(a *a)))
>>
>> Error: template instance f662.main.ReturnType!((a) => a * a) 
>> does not match template declaration ReturnType(func...) if 
>> (func.length == 1 && isCallable!func)
>
> Ah, I see. I'd like to test something; can you please change 
> `(a) => a * a` to
> `(int a) => a * a` and post the results?

Thanks for the reply. But the issue was about knowing the type of 
lambda in map. Most people won't enter the type of argument in a 
map. Is there a way to detect the return type will be non void. 
The return type is not much necessary here I just need to verify 
the function is not void.


More information about the Digitalmars-d-learn mailing list