Move Constructor Syntax
RazvanN
razvan.nitu1305 at gmail.com
Wed Oct 9 09:17:04 UTC 2024
On Wednesday, 9 October 2024 at 08:38:52 UTC, Jonathan M Davis
wrote:
> On Wednesday, October 9, 2024 12:54:21 AM MDT Manu via
This PR: https://github.com/dlang/dmd/pull/16429 implements the
generation of multiple copy constructors as described by
Jonathan. It's green and if merged it would alleviate the issues
for fields with copy constructors. However, for the
metaprogramming part there really isn't any way to identify
whether a templated function is a copy constructor without
instantiating the copy constructor, therefore the compiler cannot
know whether such a struct has a copy constructor or not.
Marking the copy constructor with some particular syntax will
solve the problem, however, you still need to perform some checks
upon instantiation to make sure the that instantiated function
respects the copy constructor signature.
Also, I agree with Jonathan and Paul that any discussion
regarding the syntax of the move constructor should also include
the copy constructor since we want to have consistent syntax
across special functions. We don't want to have:
```d
struct S
{
this(ref S s); // copy constructor
=this(S s); // move constructor
... or ...
this.move;
}
```
Regards,
RazvanN
More information about the Digitalmars-d
mailing list