DIP 1016--ref T accepts r-values--Formal Assessment
jmh530
john.michael.hall at gmail.com
Thu Jan 31 22:26:39 UTC 2019
On Thursday, 31 January 2019 at 21:57:21 UTC, Steven
Schveighoffer wrote:
> [snip]
>
> That being said, you can look at the fact that most people
> don't even know about this problem, even seasoned veterans, as
> a sign that it's really not a big problem.
>
The way you put it makes it sound like a bug...
I don't know if it helps, but below compiles without error.
struct Foo
{
private int _x;
int* x() { return &_x; }
}
struct Bar
{
private Foo _y;
Foo* y() { return &_y; }
void y(Foo foo) { _y = foo; }
}
void main() {
Foo a = Foo(1);
assert(*a.x == 1);
*a.x *= 2;
assert(*a.x == 2);
Bar b;
b.y = Foo(1);
assert(*b.y.x == 1);
*b.y.x *= 2;
assert(*b.y.x == 2);
}
More information about the Digitalmars-d-announce
mailing list