fork download
  1. import std.stdio;
  2.  
  3. struct S
  4. {
  5. this(this)
  6. {
  7. writeln("this");
  8. }
  9.  
  10. S opAssign(S s)
  11. {
  12. writeln("opAssign");
  13. return s;
  14. }
  15. }
  16.  
  17. ref S func(ref S s)
  18. {
  19. return s;
  20. }
  21.  
  22. void main()
  23. {
  24. S a;
  25. writeln("-1-");
  26. S b = a;
  27. writeln("-2-");
  28. b = a;
  29. writeln("-3-");
  30. b = func(a);
  31. }
Success #stdin #stdout 0.01s 2120KB
stdin
Standard input is empty
stdout
-1-
this
-2-
this
opAssign
this
-3-
opAssign
this