But I want to know how C++ actualy implement this, Well, how the compiler implements this feature is up to the compiler alone, I guess. You can assume the internally generated code will resemble in some way the following:
static bool __f_a_initialized=false;
static char __f_a_storage[sizeof(classA)];
void f()
{
if(!__f_a_initialized){
new (__f_a_storage) class A; // constructs a classA onto __f_a_storage
__f_a_initialized=true;
}
...
}
Do not take this as the actual procedure implemented, it is just an approximation to what the compiler probably does. Does this answer your question? And I want to know whether doing inline of f() will break the rule? The rule does not break even if you declare your function inline. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo Want a Boost forum in Code Project? Vote here[^]!