cannot modify struct with immutable members

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jan 2 21:11:33 PST 2015


On Sat, 03 Jan 2015 14:45:24 +1030
ted via Digitalmars-d-learn <digitalmars-d-learn at puremagic.com> wrote:

p.s. also please note that structs in D are always passed by value and
copied (until you not explicitly ask for something another). so:

  MyStruct a;
  MyStruct b;
  b = a;

actually does `memcpy()` (with postblit if there is any). and it's
forbidden to overwrite `const` variable contents. that's why compiler
complains: by assigning to `mA` you are trying to overwrite contents of
`const` variable.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20150103/811172f9/attachment.sig>


More information about the Digitalmars-d-learn mailing list