Boost logo

Boost Users :

From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2008-01-23 08:40:43


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

On Jan 23, 2008 12:41 PM, Tobias Schwinger <tschwinger_at_[hidden]> wrote:

> Ovanes Markarian wrote:
> > 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).
>
> Singleton is created on demand.
>
>



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net