Thoughts from newcommer
Jack Stouffer via Digitalmars-d
digitalmars-d at puremagic.com
Tue Apr 11 14:06:28 PDT 2017
On Tuesday, 11 April 2017 at 20:48:13 UTC, Piotr Kowalski wrote:
> Is it in std already? How do I allocate equivalent of
> std::vector on heap with RAII in D that will be disposed at the
> end of the scope automatically?
You're asking about two different things here.
RAII is already in the language. As soon as a struct exits its
scope, its destructor is called.
Specifically for a vector type with elements allocated on the
heap that is destroyed on scope exit, I would look at
https://dlang.org/phobos/std_container_array.html
If you want a more performant version that is integrated with
std.experimental.allocator, then I would look at
https://github.com/economicmodeling/containers
More information about the Digitalmars-d
mailing list