Rebooting the __metada/__mutable discussion
rikki cattermole
rikki at cattermole.co.nz
Fri Apr 8 18:00:14 UTC 2022
Here is my test code that I used to determine what I needed to do to
make const RC types useless (and hopefully safe).
```d
void main() {
auto r1 = /+const+/ Reference(2);
const r2 = r1;
const r3 = Reference(2);
const(Reference) r4 = Reference(2);
//auto r5 = cast(const)r1;
auto r6 = cast(void*)&r1;
auto r7 = cast(const)&r1;
}
struct Reference {
int x;
@safe:
this(int value) {
this.x = value;
}
this(ref Reference other) {
this.x = other.x;
}
~this() {
this.x = 0;
writeln("destructor");
}
void opAssign(ref Reference other) {
__ctor(other);
}
void opAssign(Reference other) {
__ctor(other);
}
// bool isNull() { ... }
@disable this(int value) const;
//@disable this(ref Reference other) const;
@disable this(ref const Reference other) const;
@disable this(this);
//@disable ~this() const;
@disable void opAssign(ref Reference other) const;
@disable void opAssign(Reference other) const;
@disable auto opCast(T)();
}
```
More information about the Digitalmars-d
mailing list