static static

BCS none at anon.com
Tue Nov 10 12:21:16 PST 2009


Hello bearophile,

> When I convert a function to a templated function (for example because
> I know the value of an argument at compile time, so using a template
> gives me a poor's man partial compilation) the static variables get
> duplicated for each instance of the function template, and I may need
> to use true global variables/constants (but if you use link-time
> optimization then LDC is able to remove such shared constants).
> 
> So I was thinking about a "static static" attribute that avoid moving
> the statics to globals. Is this a useless idea?
> 
> Bye,
> bearophile

you can kida cheet with a template scope variable

template Foo(T...) // unique var for each set of args.
{
    int bar;
}





More information about the Digitalmars-d mailing list