Challenge: write a reference counted slice that works as much as possible like a built-in slice
Walter Bright
newshound2 at digitalmars.com
Wed Dec 15 10:13:47 UTC 2021
On 12/14/2021 4:51 AM, Stanislav Blinov wrote:
>> That's what I did after reading your message, with the bonus of slapping @safe
>> on `S.__dtor` as well ;)
>>
>> ```d
>> import std.stdio:writeln;
>>
>> struct S{
>> @disable this();
>> ~this()@safe/*now @safe*/{
>> writeln("dtor!");
>> }
>> }
>>
>> void main()@safe/* now @safe*/{
>> S s = void;
>> }
>> ```
>>
>> It defeated `@safe` ;_;
>
> Oh, right, S doesn't have any pointers. @safe only cares about void-initializing
> those.
@safe is about memory safety. The example code is not memory unsafe.
More information about the Digitalmars-d
mailing list