Strange error

MichaelJames MichaelJamesuN63 at yahoo.com
Mon Mar 22 07:52:14 UTC 2021


On Sunday, 21 March 2021 at 07:18:10 UTC, Jack Applegame wrote:
> Could someone please explain what is wrong with this code?
>
> https://glot.io/snippets/fwxn2198kv
>
> ```d
> import std.stdio;
>
> struct Sample{
>   void function() func1;
>   void function() func2;
> }
>
> void noth(Sample smpl)() {
>   smpl.func1(); // Error: expression __lambda1 is not a valid 
> template value argument
>   smpl.func2(); // Error: expression __lambda2 is not a valid 
> template value argument
> }
>
> void main(){
>   enum s = Sample(
>     {writeln("Hello world1");},
>     {writeln("Hello world2");}
>   );
>   s.func1();
>   s.func2();
>   noth!(s)();
> }
> ```

Tell me, did you manage to solve this problem?


More information about the Digitalmars-d-learn mailing list