Supertypes, subtypes, and more
Tobias Pankrath via Digitalmars-d
digitalmars-d at puremagic.com
Wed Jun 25 14:10:52 PDT 2014
> 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.
More information about the Digitalmars-d
mailing list