Re: How are extra copy constructor parameters used?

2021-12-29 Thread Rahul Sharma via Digitalmars-d-learn
On Thursday, 30 December 2021 at 01:04:10 UTC, Ali Çehreli wrote: The second item in the documentation mentions "any number of default parameters" when describing copy constructor syntax: https://dlang.org/spec/struct.html#struct-copy-constructor 1) I can't figure out how to use those extra

Re: How are extra copy constructor parameters used?

2021-12-29 Thread Tejas via Digitalmars-d-learn
On Thursday, 30 December 2021 at 04:42:06 UTC, Tejas wrote: On Thursday, 30 December 2021 at 01:04:10 UTC, Ali Çehreli wrote: The second item in the documentation mentions "any number of default parameters" when describing copy constructor syntax: https://dlang.org/spec/struct.html#struct-co

Re: How are extra copy constructor parameters used?

2021-12-29 Thread Tejas via Digitalmars-d-learn
On Thursday, 30 December 2021 at 01:04:10 UTC, Ali Çehreli wrote: The second item in the documentation mentions "any number of default parameters" when describing copy constructor syntax: https://dlang.org/spec/struct.html#struct-copy-constructor 1) I can't figure out how to use those extra

Re: How are extra copy constructor parameters used?

2021-12-29 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 30 December 2021 at 02:04:30 UTC, Ali Çehreli wrote: On 12/29/21 5:14 PM, Paul Backus wrote: 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

Re: How are extra copy constructor parameters used?

2021-12-29 Thread Ali Çehreli via Digitalmars-d-learn
On 12/29/21 5:14 PM, Paul Backus wrote: 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. Excellent point. I noti

Re: How are extra copy constructor parameters used?

2021-12-29 Thread Paul Backus via Digitalmars-d-learn
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

How are extra copy constructor parameters used?

2021-12-29 Thread Ali Çehreli via Digitalmars-d-learn
The second item in the documentation mentions "any number of default parameters" when describing copy constructor syntax: https://dlang.org/spec/struct.html#struct-copy-constructor 1) I can't figure out how to use those extra parameters. For example, I can't find a special function name to c