Static variables in template functions
Nathan Sidwell
nathan@codesourcery.com
Sun Apr 17 09:26:00 GMT 2005
Mark Mitchell wrote:
> 1. Adopt a coding standard for V3 that forbids static variables with
> constant initializers in template/inline functions. Downside:
> painful for V3 developers.
And also pessimizes systems _with_ weak support. (Though as Paolo
says, this instance is not performace critical.)
> 3. Modify the compiler to initialize such variables dynamically,
> thereby eliminating the problem. Downside: pessimizes code.
I agree with your reasoning that this is the appropriate solution.
[Although, in general, the compiler is not permitted to turn static
initialization into dynamic initialization, I think for such
function-scope constant initializers, a program cannot tell the
difference -- but make sure we still treat the variable as a
constan for the remainder of the function.]
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
More information about the Libstdc++
mailing list