cast overly permissive with extern(C++ ) classes; should cast through `void*`

Seb seb at wilzba.ch
Tue Feb 6 23:18:01 UTC 2018


On Tuesday, 6 February 2018 at 23:15:07 UTC, Timothee Cour wrote:
>> Like assumeUnique?
> https://dlang.org/library/std/exception/assume_unique.html
>
> what do you mean? u mean adding "unique" to the DSL list ? 
> maybe!


You asked: Actually how about introducing a library solution for 
explicit casting.
That's why I thought about the existing assumeUnique:


```
immutable(T)[] assumeUnique(T)(ref T[] array) pure nothrow
{
     auto result = cast(immutable(T)[]) array;
     array = null;
     return result;
}
```

https://github.com/dlang/phobos/blob/v2.078.1/std/exception.d#L905


More information about the Digitalmars-d mailing list