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

deadalnix deadalnix at gmail.com
Mon Nov 8 22:16:50 UTC 2021


On Monday, 8 November 2021 at 22:07:46 UTC, Adam Ruppe wrote:
> On Monday, 8 November 2021 at 21:42:12 UTC, Andrei Alexandrescu 
> wrote:
>> - work with qualifiers like T[] does, both RCSlice!(qual T) 
>> and qual(RCSlice!T)
>
> I think this is an incorrect requirement. A const(T) is now 
> allowed to increase a reference count by definition.
>
> It in theory might still allow borrowing a reference, since 
> there'd be no net change in reference count there and thus the 
> data can remain immutable, but if isn't statically guaranteed 
> to be balanced, you're directly in contradiction with the const 
> rule.

To quote Herb Sutter, because it seems to be the fashion of the 
day, const actually means thread safe.

This is not a joke.


More information about the Digitalmars-d mailing list