digitalmars.D.learn - opApply + const
- ryuukk_ (24/24) Jan 23 Hello,
- Alexandru Ermicioi (2/26) Jan 23 Try making opApply const.
- ryuukk_ (3/37) Jan 23 Thanks that fixed it
- Paul Backus (2/10) Jan 23 https://issues.dlang.org/show_bug.cgi?id=24353
- ryuukk_ (3/16) Jan 23 Thanks, the error message was confusing me..
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?
Jan 23
On Tuesday, 23 January 2024 at 16:11:25 UTC, ryuukk_ wrote: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?Try making opApply const.
Jan 23
On Tuesday, 23 January 2024 at 17:07:18 UTC, Alexandru Ermicioi wrote:On Tuesday, 23 January 2024 at 16:11:25 UTC, ryuukk_ wrote:Thanks that fixed itHello, 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?Try making opApply const.
Jan 23
On Tuesday, 23 January 2024 at 16:11:25 UTC, ryuukk_ wrote: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?https://issues.dlang.org/show_bug.cgi?id=24353
Jan 23
On Tuesday, 23 January 2024 at 17:22:25 UTC, Paul Backus wrote:On Tuesday, 23 January 2024 at 16:11:25 UTC, ryuukk_ wrote:Thanks, the error message was confusing me.. I tried to fix it https://github.com/dlang/dmd/pull/16086It 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?https://issues.dlang.org/show_bug.cgi?id=24353
Jan 23