Thread overview | ||||||
---|---|---|---|---|---|---|
|
September 20, 2018 automem v0.3.5 - now with more vector (like std::vector, not Physics)! | ||||
---|---|---|---|---|
| ||||
If you've never heard of automem before, I wrote it to have C++-style smart pointers in D that I could use in @nogc code: http://code.dlang.org/packages/automem I needed something like a std::vector that can be @nogc so I wrote it. I wondered whether or not to put it in a collections package or not, then punted on the decision and just stuck it in automem. Anyway, code: // *no* GC allocations below if theAllocator is set to an allocator that // never allocates on the GC heap import automem.vector; // there's an `array` alias too auto v = vector(0, 1, 2); v ~= 3; v ~= only(4, 5); assert(v[] == [0, 1, 2, 3, 4, 5]); If you want the @nogc compile-time guarantee, specify an allocator: () @nogc { auto v = vector!Mallocator(0, 1, 2, 3); v ~= only(4, 5, 6); // etc. }(); Enjoy (hopefully)! |
September 20, 2018 Re: automem v0.3.5 - now with more vector (like std::vector, not Physics)! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Atila Neves | On Thursday, 20 September 2018 at 14:57:42 UTC, Atila Neves wrote:
> If you've never heard of automem before, I wrote it to have C++-style smart pointers in D that I could use in @nogc code:
>
> [...]
Official bindings to std::vector will soon be added by manu. (I think)
|
September 30, 2018 Re: automem v0.3.5 - now with more vector (like std::vector, not Physics)! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Atila Neves | On Thursday, 20 September 2018 at 14:57:42 UTC, Atila Neves wrote: > If you've never heard of automem before, I wrote it to have C++-style smart pointers in D that I could use in @nogc code: > > > http://code.dlang.org/packages/automem > > Sorry for asking here. Shouldn't this code work? import automem; struct X { int i; } struct Y { RefCounted!X x; // fails //X x; // ok } void main() { Y y1; Y y2; y2 = y1; } https://run.dlang.io/is/k2qWhm |
October 01, 2018 Re: automem v0.3.5 - now with more vector (like std::vector, not Physics)! | ||||
---|---|---|---|---|
| ||||
Posted in reply to ikod | On Sunday, 30 September 2018 at 19:54:07 UTC, ikod wrote:
> On Thursday, 20 September 2018 at 14:57:42 UTC, Atila Neves wrote:
>> If you've never heard of automem before, I wrote it to have C++-style smart pointers in D that I could use in @nogc code:
>>
>>
>> http://code.dlang.org/packages/automem
>>
>>
>
> Sorry for asking here.
>
> Shouldn't this code work?
>
> import automem;
>
> struct X {
> int i;
> }
> struct Y {
> RefCounted!X x; // fails
> //X x; // ok
> }
> void main()
> {
> Y y1;
> Y y2;
> y2 = y1;
> }
>
> https://run.dlang.io/is/k2qWhm
This really should have been a github issue, but thanks for posting this anyway. I just fixed it.
|
Copyright © 1999-2021 by the D Language Foundation