can we un-deprecate .ptr on arrays in @safe code? cf issue 18529
Seb
seb at wilzba.ch
Tue Feb 27 20:47:52 UTC 2018
On Tuesday, 27 February 2018 at 11:33:04 UTC, Simen Kjærås wrote:
> That only checks if the first element is the same. For a full
> 'is slice' check you'd need something like this:
>
> assert(a.ptr <= b.ptr && b.ptr + b.length <= a.ptr +
> a.length);
>
> // Or:
>
> auto c = b.ptr - a.ptr;
> assert(c >= 0 && c + b.length <= a.length);
>
> And trust me, the compiler complains about both of these.
> Possibly rightfully in the first example, but the latter never
> does anything scary with the given pointers.
>
> --
> Simen
aka isSliceOf -> https://github.com/dlang/phobos/pull/6147
More information about the Digitalmars-d
mailing list