Right ways to work without gc without betterC.

Konstantin kostya.hm2 at gmail.com
Fri May 1 22:55:14 UTC 2020


I saw docs for std.experimental.allocator and also had found
automem library(https://code.dlang.org/packages/automem) for c++ 
style memory management via smartpointers.

 From GC documentation std.experimental.allocator can not be used 
for:
     NewExpression
     Array appending
     Array concatenation
     Array literals (except when used to initialize static data)
     Associative array literals
     Any insertion, removal, or lookups in an associative array
     Extracting keys or values from an associative array
     Taking the address of (i.e. making a delegate to) a nested 
function that accesses variables in an outer scope
     A function literal that accesses variables in an outer scope
     An AssertExpression that fails its condition

Is that actual information? Does someone work to implement switch 
between gc and non-gc approach?

I learned for now automem's smartpointers which based on 
std.experimental.allocator can be used to store structs/classes.
Does automem(or std.experimental.allocator) has support for 
inherited classes,
polymorphism like std::unique_ptr<ISomeInterface> (or base class) 
in c++?

Does Phobos support std.experimental.allocator?

Are there another gotchas with "c++ like" memory management way 
in D?

P.S. Sorry for my bad english.



More information about the Digitalmars-d-learn mailing list