On 15 July 2013 18:50, Iain Buclaw <ibuclaw@ubuntu.com> wrote:
On 15 July 2013 16:22, Don Clugston <dclugston@gmail.com> wrote:
>
>
> On 15 July 2013 11:46, Iain Buclaw <ibuclaw@ubuntu.com> wrote:
>>
>> But for floor and ceil, at least one of the following must be
>> available in CTFE to allow setting bits.
>>
>> ----
>> // Cannot convert &real to ushort* at compile time
>> real y = x;
>> ushort* sh = cast(ushort*)&y;
>
>
>
> Yeah. The problem with this, is that what happens if somebody stores the
> pointer? It introduces loads of special cases.
>
> The most minimal solution would be to explicitly allow:
>
> ushort e = *(cast ushort *)&y;
> *(cast ushort *)&y = e;
>

Hmm, how about static arrays of the same size?  This is safer because
of copy semantics (e is a copy of y).

ushort[8] e = *cast(ushort[8]*)&y;
y = *cast(real *)&e;

True. But I don't think you would ever write runtime code that way, it seems quite unnatural since it is so slow.
Could certainly be done.