fork download
  1. import std.stdio;
  2.  
  3. class X
  4. {
  5. int p_prop;
  6.  
  7. @property auto x() { return P!(int, "p_prop")(this.p_prop, this); }
  8.  
  9. struct P(T, string p)
  10. {
  11. T v; X c;
  12. mixin("alias v this;");
  13.  
  14. ~this()
  15. {
  16. mixin("this.c." ~ p ~ " = " ~ this.v.stringof ~ ";");
  17. }
  18. }
  19. }
  20.  
  21. void main()
  22. {
  23. X y = new X();
  24.  
  25. y.x += 50;
  26. y.x *= 3;
  27. writeln(y.p_prop);
  28. }
  29.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.d(25): Error: 'y.x' is not a scalar, it is a P!(int,"p_prop")()
prog.d(25): Error: incompatible types for ((y.x) += (50)): 'P!(int,"p_prop")()' and 'int'
prog.d(26): Error: 'y.x' is not a scalar, it is a P!(int,"p_prop")()
prog.d(26): Error: incompatible types for ((y.x) *= (3)): 'P!(int,"p_prop")()' and 'int'
stdout
Standard output is empty