Get return type statically

Smoke Adams via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jun 27 18:44:53 PDT 2016


On Tuesday, 28 June 2016 at 01:41:03 UTC, "Smoke" Adams wrote:
> I have a type
>
> public class SuperFunction(T)
> {
>   T t;
>   return(T) Do() { return t(); }
> }
>
> where T is a delegate or function. First, I would like to be 
> able to specify that this must be the case for SuperFunction so 
> we can't pass non-function/delegates for T. Second, How to 
> specify the return type of Do to match that of T.
>
> e.g., SuperFunction!(bool function())
>
> then return(T) should be bool.
>
> Similarly, I would like to extra the T's parameters and make Do 
> have them also.
>
> This way, SuperFunction!T.Do emulates T in every way.

I should mention that I am looking to make this as type safe as 
possible as if Do was declared exactly like T manually.






More information about the Digitalmars-d-learn mailing list