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
  • 121,188
  • 31
  • 271
  • 414
Max Frai
  • 57,874
  • 75
  • 193
  • 301
  • 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
  • 246,832
  • 83
  • 321
  • 542
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
  • 52,418
  • 9
  • 90
  • 139