Many thanks that works fine! The singleton is really created on request.
I have one additional question about destruction of singletons. This simple example was compiled with VC++ 7.1
#include <boost/utility/singleton.hpp>
#include <iostream>
class my_singleton : public boost::singleton<my_singleton>
{
public:
my_singleton(boost::restricted)
{
std::cout << "ctor called\n";
}
~my_singleton()
{
__debugbreak();
std::cout << "dtor called\n";
}
}
int main()
{
my_singleton::lease l;
return 0;
}
This successfully creates a singleton but never calls the dtor of it. Should I always call explicitly destroy_singletons function?
Many thanks for the great lib!
Ovanes
Ovanes Markarian wrote:Singleton is created on demand.
> Hello,
>
> I am currently evaluating boost.singleton for our application. I hope it
> is not too late to write a review. As I understood from the docs,
> Singleton instance is immediately (when all global and static variables
> are initilized) created. In our context we need singleton to be created
> on first request (as it is described in GoF).