Issue 1974 - What's your opinion?
kinke
noone at nowhere.com
Fri Oct 25 01:20:02 UTC 2019
On Thursday, 24 October 2019 at 08:02:28 UTC, RazvanN wrote:
> What are your thoughts on this? Should be close the issue as an
> invalid one?
I'm clearly in favor of the filed issue, i.e., see it as valid.
This is for consistency with primitive types, and lvalue-ness is
IMO a clear intrinsic requirement for a (bin)assign operator's
left hand side:
```
struct S { int i; }
struct O
{
int i;
void opOpAssign(string op)(int) {}
}
T make(T)() { return cast(T) 1; }
void foo()
{
make!int() += 2; // Error: `make()` is not an lvalue and
cannot be modified
make!S() += 2; // Error: `make()` is not an lvalue and
cannot be modified
make!O() += 2; // compiles
}
```
Allowing rvalues for an explicit opOpAssign!"+" call is IMO fine,
but not when using the operator, as that's just a leaking
implementation detail.
More information about the Digitalmars-d
mailing list