On Thursday, 30 December 2021 at 01:04:10 UTC, Ali Çehreli wrote:
2) Unlike the examples there, I think the parameter should most usefully be defined as 'const' unless there is a special reason:

struct S {

  // const(S) instead of S:
  this(ref const(S) that) {
  }
}

Do you agree?

When the compiler generates a copy constructor for you, it always qualifies both the source and destination objects with `inout`:

https://dlang.org/spec/struct.html#implicit-copy-constructors

Therefore, when you write your own copy constructors, you should always use `inout` if possible, so that compiler-generated copy constructors will be able to copy instances of your struct that appear as members of other structs.

Reply via email to