On Thu, Sep 21, 2017 at 09:49:14PM +0200, ag0aep6g via Digitalmars-d-learn 
wrote:
[...]
> 3) Declaring a packed struct in a function literal that gets
> immediately called:
> ----
> enum size_so_very_clever(Types ...) = () {
>     struct S { align(1) Types fields; }
>     return S.sizeof;
> } ();
> ----

I'd just do:

        template sizeofStruct(Types...) {
                struct S { align(1) Types fields; }
                enum sizeofStruct = S.sizeof;
        }

Skip the CTFE implied by the function literal, the compiler already
knows the size very well.


T

-- 
What are you when you run out of Monet? Baroque.

Reply via email to