how to assign to shared obj.systime?

Steven Schveighoffer schveiguy at
Mon Jul 13 01:56:44 UTC 2020

On 7/11/20 1:03 AM, Kagamin wrote:
> Steven's solution isn't good in the general case

Right, you need to know that SysTime is actually a value type, and so it 
can be implicitly copied without problems with aliasing.

In fact, the cast isn't needed to ensure there is no lingering aliasing. 
I can tell it's a value type because:

const SysTime x;
SysTime y;
y = x; // ok.

Likewise, I technically could just copy to a shared one, but the problem 
is that the actual act of writing the field is subject to memory 
problems. It has nothing to do with the SysTime internals.

To make the solution more "correct" you could mark the incoming SysTime 
as const.


More information about the Digitalmars-d-learn mailing list