Structs should not contain pointers to internal data
Saurabh Das
saurabh.das at silverleafcaps.com
Mon Jun 3 05:26:58 PDT 2013
Thank you @Ali and @Jonothan!
So essentially since I will be storing a pointer, Telemetry!(T) is NOT safe
to use only with structs in general.
If I have something like:
struct UsefulStruct2
{
this(this) @disable;
this(UsefulStruct2) @disable;
this(ref const(UsefulStruct2)) @disable;
ref UsefulStruct2 opAssign(UsefulStruct2) @disable;
ref UsefulStruct2 opAssign(ref const(UsefulStruct2)) @disable;
int importantValue;
auto tel1 = Telemetry!int(importantValue);
}
Does that ensure that UsefulStruct2 is not relocateable and thus I can
safely store a pointer to importantValue?
If not, what constraints do I need to add to my classes to ensure that I
don't run into subtle bugs when structs relocate?
Regards,
Saurabh Das
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20130603/19a09085/attachment.html>
More information about the Digitalmars-d-learn
mailing list