Structs should not contain pointers to internal data
Ali Çehreli
acehreli at yahoo.com
Sun Jun 2 22:19:45 PDT 2013
On 06/02/2013 09:53 PM, Saurabh Das wrote:
> structs should be bit-wise relocatable and
> hence should not contain pointers to internal data members.
That's correct. I can't find at this time what part of the spec you are
quoting. :) I was wondering whether it specifically says pointer, or
reference in its general meaning.
> struct Telemetry(T) ...
>
> struct UsefulStruct
> {
> int importantValue;
> auto tel1 = Telemetry!int(importantValue);
> }
>
> Essentially I'm asking whether the above is a valid construct in D.
The answer is based on the fact that struct objects can be freely
relocated. Will UsefulStruct work correctly when that happens? If yes,
then it is valid.
Ali
More information about the Digitalmars-d-learn
mailing list