|
|
|
|
|
by kazinator
338 days ago
|
|
The way block scope statics are handled in C++ is a mistake. Block scope statics that don't depend on any non-static local variables should be initialized when the program starts up. E.g.: void fun(int arg)
{
static obj foo(arg); // delayed until function called (dependency on arg)
static obj bar(); // inited at program start (no dependency on arg)
}
In other words, any static that can be inited at program startup should be, leaving only the troublesome cases that depend on run-time context. |
|