Forward a single field to a subfield, "alias this"-style?

Vladimir Panteleev vladimir at thecybershadow.net
Tue Sep 6 14:03:03 PDT 2011


What I'm trying to do:

struct S1 { int f; }
struct S2
{
	S1 s1;
	alias s1.f g;
}

This doesn't work. The declaration compiles, but attempts to access g  
result in:

Error: struct test.S2 'f' is not a member
Error: struct test.S2 member f is not accessible
Error: this for f needs to be type S1 not type S2

I could generate @properties with mixins, but that breaks DDoc. Is there a  
neater solution?

-- 
Best regards,
  Vladimir                            mailto:vladimir at thecybershadow.net


More information about the Digitalmars-d-learn mailing list