automem v0.0.7 - C++ style smart pointers using std.experimental.allocator

Basile B. via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Sun Apr 9 08:52:50 PDT 2017


On Sunday, 9 April 2017 at 08:56:52 UTC, Atila Neves wrote:
> Using std.experimental.allocator? Tired of writing `scope(exit) 
> allocator.dispose(foo);` in a language with RAII? Me too:
>
>
>
> http://code.dlang.org/packages/automem
>

I think that the Array misses
- a reservation strategy, something like reserve() and allocBy().
- dup / idup that return new distinct and deep copies.
- maybe .ptr at least for reading with pointer arithmetic.
- opBinary for "~" . Also you have bugs with operators:

```d
import std.experimental.allocator.mallocator;
UniqueArray!(int, Mallocator) a;
a ~= [0,1];
```

crashes directly.


More information about the Digitalmars-d-announce mailing list