struct S
{
public:
this(string s)
{
this.s = s;
}
// Remove 'const' will make it work
void x(scope const S v)
{
}
// Recursive calling itself because of alias value this - stack overflow
private static int xCounter = 0;
void x(string v)
{
assert(xCounter == 0);
xCounter++;
scope (exit)
xCounter--;
x(S(v));
}
@property string value()
{
return s;
}
alias value this;
private:
string s;
}
void main()
{
S s = S("a");
s.x("b");
}
Comment #1 by robert.schadek — 2024-12-13T19:08:51Z