Skip to Content
Hands-On Design Patterns with C++
book

Hands-On Design Patterns with C++

by Fedor G. Pikus
January 2019
Intermediate to advanced
512 pages
14h 5m
English
Packt Publishing
Content preview from Hands-On Design Patterns with C++

Leaky singletons

We have just seen how Meyers' singleton solves the problem of the order of static initializations. The problem of the destruction order, on the other hand, is a different matter altogether. The order of destruction is well-defined by the standard—the static variables—the ones at the function scope, as well as the ones at the file scope—are destroyed after the program itself terminates (after the return from main()). The destruction is done in the opposite order to that of construction; that is, the object that was constructed last is destroyed first. Why is this a concern?

First of all, we can say with certainty that any references to a singleton object in the program itself (and not in other static objects) are definitely ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Structural Design Patterns in Modern C++

Structural Design Patterns in Modern C++

Umar Lone

Publisher Resources

ISBN: 9781788832564Supplemental Content