Another compile-time perversion. Or not?
Walter Bright
newshound at digitalmars.com
Fri Sep 1 10:54:44 PDT 2006
Don Clugston wrote:
> Walter Bright wrote:
>> There's a bit of chicken and egg problem with it - can't tell if it's
>> referenced or not until code generation, which is intimately wrapped
>> up with object file generation.
>
> But isn't it true that a template consisting only of
> 'const' and 'static if' will *never* result in code generation?
There can be:
template Foo(T)
{
static if (...)
const T x;
}
int* p = &Foo!(int).x;
> After it
> has been constant folded, it will always be safe to discard it.
>
> That might not cover all of the theoretically discardable templates, but
> it would give almost all of the practical benefits.
More information about the Digitalmars-d-announce
mailing list