
8 Aug
2006
8 Aug
'06
3:10 p.m.
AlisdairM wrote:
However, I freely admit I have no idea how to test if something uses static initialization or dynamic.
Todd Greer already posted one possible test, but a much simpler version is extern array<int, 2> a; int x = a[0]; array<int, 2> a = { 1, 2 }; int main() { assert( x == 1 ); } As you state, it works only on compilers that get order of initialization (and a few other portions of the C++ standard) correct. :-)