New abstraction: Layout

Dmitry Olshansky dmitry.olsh at gmail.com
Sun Feb 18 09:52:03 UTC 2018


On Saturday, 17 February 2018 at 19:37:12 UTC, Steven 
Schveighoffer wrote:
> On 2/17/18 9:59 AM, Andrei Alexandrescu wrote:
>> On 02/17/2018 09:03 AM, Steven Schveighoffer wrote:
>>> I found this also works:
>>>
>>> static foreach(alias x; S.tupleof)
>>> {
>>>     writeln(x.offsetof);
>>> }
>> 
>> Yes, the implementation uses offsetof.
>> 
>
> I guess I'm just confused based on the statement "the builtin 
> .tupleof ... [omits] the essential information of field 
> offsets."
>
> What is this construct giving us that .tupleof doesn't?
>

I guess the construct captures offsets as part of type. This is 
useful for allocators + 2 things with same Layout can be 
bitblitted to each other.

> -Steve




More information about the Digitalmars-d mailing list