Feature: `static cast`

Nick Treleaven nick at geany.org
Tue Jul 4 17:09:25 UTC 2023


On Monday, 3 July 2023 at 18:15:43 UTC, Paul Backus wrote:
> On Monday, 3 July 2023 at 17:51:19 UTC, Nick Treleaven wrote:
>> I tried but it doesn't seem to work:
>>
>> ```d
>> class C
>> {
>>     int* opCast(T)()
>>     if (is(T == void*)) => new int(42);
>> }
>>
> It calls `opCast`, and then implicitly converts the result from 
> `int*` to `void*`.

Ah, thanks. So that implicit cast prevents the return type of 
opCast potentially being completely different from the `cast` 
type.



More information about the Digitalmars-d mailing list