Marc Glisse <marc.gli...@inria.fr> writes: > On Mon, 5 Oct 2015, Richard Sandiford wrote: > >>> I do believe you still have some code growth since the inline dconst >>> function always expands code that will initialize the constant. IMO >>> that's not desirable. >> >> I don't disagree. I find dconst0 much easier to read than dconst<0> (). >> In some ways I was posting the patch to show how bad it could be :-) >> >> If we're prepared to pay the cost of unconditional load-time >> initialisation, we could have: >> >> template <int N> >> struct dconst_value >> { >> dconst_value () { ...set up value ...; } >> REAL_VALUE_TYPE value; >> }; >> >> template <int N> >> const REAL_VALUE_TYPE & >> dconst<T> (void) >> { >> static dconst_value<N> x; >> return x.value; >> } > > Why are you calling this load-time initialization? As far as I know, such > a static object is still initialized lazily (with all the overhead this > implies). Did you mean to make value a static member of dconst_value?
Bah, of course, sorry.