Thank you!

Mike Parker aldacron at gmail.com
Wed Sep 8 07:25:52 UTC 2021


On Wednesday, 8 September 2021 at 06:03:49 UTC, Tejas wrote:

> Please allow this to compile.
> `int` is value type, so it is fine to generate a temporary and 
> allow the code to compile, right? A small test will reveal that 
> `integer` is not being modified, so it's not **that** big of a 
> deal, right?

There's a big difference between int and struct: the latter is an 
aggregate that may have member functions that have side effects. 
For example:

```d
getTemporary().doSomethingWithSideEffects();
```

That's a valid pattern. You might then say that's a different 
case than the assignment in your example, but `opAssign` for a 
struct can be overridden.



More information about the Digitalmars-d mailing list