Arrays of structs

BBasile via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Aug 27 04:15:55 PDT 2015


On Thursday, 27 August 2015 at 10:49:02 UTC, John Burton wrote:
> Thanks again for the updates. I've experimented some more and 
> believe I understand.
>
> To be honest I'm finding it very hard to find the right idioms 
> in D for safe and efficient programming when I'm so used to C++ 
> / RAII everywhere. I'll adapt though :P

You can also do explicit
* memory allocation/deallocation
* class construction/destruction
* struct/union construction/destruction

Personally my background is Object-Pascal/Delphi which use 
similar memory managment to C++ (though more RAII with ownership 
than RAII with refcounting). For example I have those routines in 
my home-cooked general library:

https://github.com/BBasile/iz/blob/master/import/iz/types.d#L125
https://github.com/BBasile/iz/blob/master/import/iz/types.d#L150
https://github.com/BBasile/iz/blob/master/import/iz/types.d#L191

they allow to do manual memory managment and you'll find similar 
routines in several other user libraries, for example
* https://github.com/etcimon/memutils
* https://github.com/Dgame/m3
* etc...




More information about the Digitalmars-d-learn mailing list