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

Atila Neves via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Sun Apr 9 03:22:49 PDT 2017


On Sunday, 9 April 2017 at 09:36:53 UTC, Martin Nowak wrote:
> On Sunday, 9 April 2017 at 08:56:52 UTC, Atila Neves wrote:
>> I benchmarked RefCounted against C++'s std::shared_ptr 
>> comparing ldc to clang using both shared and non-shared 
>> payloads in D. std::shared_ptr is faster (I've never written a 
>> smart pointer before), but the advantage of non-atomic 
>> operations makes my D implementation just a bit faster when 
>> non-shared. I think with some work it can be significantly 
>> faster without any loss of thread safety.
>
> Nice!
> You know you can overload `this(this) shared` do you? My plan 
> was to use that for atomic RC, so that ppl. can use 
> `shared(RefCounted)` when necessary.

I did not. Thanks for telling me!

The way I wrote it RefCounted!(shared T) works - RefCounted 
doesn't have to be shared itself, but I guess it could be.

Atila


More information about the Digitalmars-d-announce mailing list