1

I'm using boost's singletons (boost::serialization::singleton). I have to control the queue of class destructings. One singleton consist of the object whicn uses object from second singleton. And I have to delete second singleton, before the first one. Can I do this?

p.s. please, don't say anything about singleton programming technique :)

Scott Chamberlain
  • 124,994
  • 33
  • 282
  • 431
Max Frai
  • 61,946
  • 78
  • 197
  • 306
  • possible duplicate of [Finding C++ static initialization order problems](http://stackoverflow.com/questions/335369/finding-c-static-initialization-order-problems) – Martin York Oct 04 '10 at 17:59

2 Answers2

1

Yes:

Read this: Finding C++ static initialization order problems

Community
  • 1
  • 1
Martin York
  • 257,169
  • 86
  • 333
  • 562
0

If you can reference the second singleton from the first using boost::weak_ptr you may be able to do what you wish to here. The first would need to make sure the weak_ptr is still live before using the second singleton.

Steve Townsend
  • 53,498
  • 9
  • 91
  • 140