From: Mattias Flodin (flodin_at_[hidden])
Date: 2001-11-13 17:44:13
On Tue, 13 Nov 2001 scleary_at_[hidden] wrote:
> Actually, the *construction* order has no guaranteed relation; the
> destruction order is guaranteed to be the reverse of the construction order.
Right, that's another way of looking at it.
> That is, by controlling when instance() is called, you can control (at least
> to some degree) the construction order, and by implication the destruction
This is interesting - I have not seen this behavior in Visual C++ 6 (in
fact, I've had to stop using such instance() functions with static
variables simply because things were not being destroyed in the right
order). But then again templates and statics tend to have problems in
general in MSVC: it seems to create several instances of the same
function-static variable in some cases. In one project we discovered we
had six separate independent instances of a singleton, because the
template class had been instantiated in six different modules. Despite
having an assert to check for multiple creation, this was not detected
because all the static variables to keep track of old instantiations were
duplicated for the new instantiations.
But I guess these are implementation or portability issues, and
probably best left to discuss later on when a general standard-compliant
design has been devised.
-- Mattias Flodin <flodin_at_[hidden]> "A good thing about C++ is that only Room D418 friends can access your private parts" Department of Computing Science Umeå University S-901 87 Umeå, Sweden Note: Any opinions expressed in this mail are personal, and do not necessarily reflect an official standpoint of Umeå University.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk