On Wednesday, 6 February 2013 at 22:29:49 UTC, Maxim Fomin wrote:
Yes, because this(const this) is not a copy constructor or a postblit, it is a simple constructor. X(x) will print "Hi". This is unintuitive, but parameter names can be omitted and this leads to confusion between struct postblit and struct constructor which has first argument of its own type.

Thanks, I did not know that. I think I see it, now:
  auto x3 = X(x);
  auto x4 = x;

The first prints "Hi", the second not. So it is not a "copy constructor", but rather a "simple constructor" that would allow for performing a copy. I assume the syntax "auto x3 = X(x)" is the only way this would be called, and by-value parameter passing would never invoke 'this(const this)'.

This begs the question:

Which of these do you choose and for what reasons:
- this(this){}
- this(this)const{}
- this(const this){}

Also, has any of this detailed information made it into the language spec?

Thanks
Dan

Reply via email to