opApply + const

ryuukk_ ryuukk.dev at gmail.com
Tue Jan 23 16:11:25 UTC 2024


Hello,

I have the following:

```D

struct Stuff {
     int opApply(scope int delegate(Stuff*) dg)
     {
         return 0;
     }

};
void main()
{
     Stuff* stuff;
     foreach(it; *stuff)
     {}
}
```

It works fine.. but when the variable becomes ``const(Stuff)* 
stuff;``

It gives me:

```
onlineapp.d(13): Error: cannot uniquely infer `foreach` argument 
types
```

I have no idea what i should be doing, does anyone have a clue?


More information about the Digitalmars-d-learn mailing list