Move Constructor Syntax
zjh
fqbqrr at 163.com
Thu Oct 10 06:56:46 UTC 2024
On Thursday, 10 October 2024 at 06:41:55 UTC, Walter Bright wrote:
>> https://forum.dlang.org/post/uvqyfedjuuerueinikwl@forum.dlang.org
>
```d
// Function bodies omitted for brevity
// mutable original
this(ref typeof(this));
this(ref typeof(this)) const;
this(ref typeof(this)) immutable;
this(ref typeof(this)) inout;
// const original
this(ref const typeof(this));
this(ref const typeof(this)) const;
this(ref const typeof(this)) immutable;
this(ref const typeof(this)) inout;
// immutable original
this(ref immutable typeof(this));
this(ref immutable typeof(this)) const;
this(ref immutable typeof(this)) immutable;
this(ref immutable typeof(this)) inout;
// inout original
this(ref inout typeof(this));
this(ref inout typeof(this)) const;
this(ref inout typeof(this)) immutable;
this(ref inout typeof(this)) inout;
// etc.
```
`C++` has a deduced this,like this:
```cpp
struct A {
template <typename Self>
void bar(this Self&& self);
};
```
More information about the Digitalmars-d
mailing list