PhobosWatch: manifest => enum

Janice Caron caron800 at googlemail.com
Fri Jan 4 10:18:03 PST 2008


On 1/4/08, Oskar Linde <oskar.lindeREM at ovegmail.com> wrote:
> struct T {
>         const int a = 5;
>         int b;
> }
>
> static assert(T.sizeof == int.sizeof);

I see a problem there. You said that a is template-like, and
instantiated only if its address is taken. That means that T itself is
template-like, because it contains a. But I don't see how it can be.
That static assert cannot compile unless T.sizeof is known. T.sizeof
may be different in different modules, since one module may take the
address of a, and another may not. For example:

    // In another module
    import module_where_T_is_declared;

    T t;
    p = &t.a;
    static assert(T.sizeof != int.sizeof);

I would imagine that would make life very difficult for things like
struct copying.



More information about the Digitalmars-d mailing list