[Issue 22792] Wrong inference of opApply
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Feb 20 12:17:41 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=22792
--- Comment #3 from moonlightsentinel at disroot.org ---
Same behaviour without the first parameter that is identical for every
overload:
struct S
{
int opApply(int delegate(ref int) dg) { puts("mutable
int"); return 0; }
int opApply(int delegate(ref const(int)) dg) const { puts("const int");
return 0; }
int opApply(int delegate(ref string) dg) { puts("mutable
str"); return 0; }
int opApply(int delegate(ref const(string)) dg) const { puts("const str");
return 0; }
}
void main()
{
S s;
foreach (ref const(int) y; s) {}
foreach (ref const(string) y; s) {}
const S s2;
foreach (ref const(int) y; s2) {}
foreach (ref const(string) y; s2) {}
}
--
More information about the Digitalmars-d-bugs
mailing list