Challenge: write a reference counted slice that works as much as possible like a built-in slice

Atila Neves atila.neves at gmail.com
Thu Nov 11 23:59:29 UTC 2021


On Thursday, 11 November 2021 at 10:06:44 UTC, Ola Fosheim 
Grøstad wrote:
> On Thursday, 11 November 2021 at 09:15:54 UTC, Atila Neves 
> wrote:
>> I have not yet encountered cases where it would be necessary 
>> that aren't "I'm implementing the standard library".
>
> Not so sure about that. Arena allocators would be done with 
> malloc, but you probably should wrap it with RAII.
>
> Allocating directly from the OS (bypassing malloc) can in some 
> cases be advantageous. But again, you are usually better off 
> creating a RAII wrapper for it.
>
> You also have dynamic stack allocation which can boost 
> performance significantly. Sadly, Walter is against having this 
> as a feature.

So use a different allocator with your vector/smart pointer/what 
have you.


More information about the Digitalmars-d mailing list