struct Foo
    {
        private SomeOtherStruct payload;
        public alias payload this;

        // ... other stuff ...
    }

... the compiler won't accept it, because the private access to payload clashes with public access via alias this.


Did you try using a method?

module1
---

struct Subtype {
private int x;
public int getX() { return x; }
alias getX this;
}
---

module2
---
import module1;
void main()
{
Subtype st = Subtype(2);
int x = st;
}
---

Works for me.

Reply via email to