What is the best way to destroy a singleton object?
case A: Single threaded Environment
case B: Multi Threaded Environment
Sample snippets(if any) will be really helpful.
[EDIT] I don't have a specific use case I am just trying to understand that IF AT ALL the singleton has to be used how to destroy it correctly. As i understand, from the comments, there are 2 scenarios possible:
1. Destroy the singleton when no code is accessing it.(use smart pointers which will take care of destroying the object by itself using RAII)
2. Destroy a singleton when exiting the program irrespective of whether or not some code was holding on to the singleton.
(explicitly destroy by deleting the instance just before main exits)