will it ?
I would have thought this particular example would work. The copy creates a new instance of TType. Then splats the contents with the contents of the supplied TType.
Surely the GC is fully aware of this new Object ?
I would have thought as long as your type doesnt contain object pointers this will work. If your Type does contain an object pointer then the memcopy will copy the pointer over but this will go unnoticed by the GC and this will cause problems.
Anyway.. Whether it works or not I would personally just write the Copy function to create a new instance and copy over the fields. Otherwise at some point in the future I might decide to add a new field which contains a string or another type and BAM!.. things will start going weird and I'd end up wondering why.
I would have thought this particular example would work. The copy creates a new instance of TType. Then splats the contents with the contents of the supplied TType.
Surely the GC is fully aware of this new Object ?
I would have thought as long as your type doesnt contain object pointers this will work. If your Type does contain an object pointer then the memcopy will copy the pointer over but this will go unnoticed by the GC and this will cause problems.
Anyway.. Whether it works or not I would personally just write the Copy function to create a new instance and copy over the fields. Otherwise at some point in the future I might decide to add a new field which contains a string or another type and BAM!.. things will start going weird and I'd end up wondering why.