Mission impossible

rikki cattermole rikki at cattermole.co.nz
Wed Apr 11 08:56:01 UTC 2018


On 11/04/2018 8:36 PM, Shachar Shemesh wrote:
> struct S {
>      static void func(T)(uint a, T t) {
>      }
> 
>      static void func() {
>      }
> }
> 
> Your mission, Jim, should you choose to accept it, is this:
> 
> Get a pointer to the version of the function that accepts no arguments.
> 
> As always, should you or any of your Force be caught or killed, the 
> Secretary will disavow any knowledge of your actions. This disc will 
> self-destruct in ten seconds.
> 
> Good luck, Jim.

import std.stdio;
void main()
{
     writeln("Hello D ", &wrapper!(S, "func"));
     wrapper!(S, "func");
}

struct S {
     static void func(T)(uint a, T t) {
         writeln("a");
     }

     static void func() {
         writeln("b");
     }
}

pragma(inline, true)
auto wrapper(T, string name, Args...)(Args args) {
     mixin("return T." ~ name ~ "(args);");
}


More information about the Digitalmars-d mailing list