I am interested to find a sound C++ implementation of a Singleton, and have attempted to find one within the Boost libraries. It seems that "pool/detail/singleton.hpp" would fit the bill for me, but (as I understand it) this class/header is not intended for direct use by library users. Have I overlooked a good alternative within the Boost suite?
Thanks, Paul
_______________________________________________
Boost-users mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
I don't think there is something in boost. Here is some research I did on
Singletons:
http://www.oneunified.net/blog/Personal/SoftwareDevelopment/CPP/Singleton.ar
ticle
http://www.oneunified.net/blog/Personal/SoftwareDevelopment/CPP/SingletonPer
Thread.article
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Kind regards,
Derik
On Tue, 2009-10-20 at 08:59 -0300, Ray Burkholder wrote:
> >
> > I am interested to find a sound C++ implementation of a Singleton, and
> > have attempted to find one within the Boost libraries. It seems that
> > "pool/detail/singleton.hpp" would fit the bill for me, but (as I
> > understand it) this class/header is not intended for direct use by
> > library users. Have I overlooked a good alternative within the Boost
> > suite?
> >
>
> I don't think there is something in boost. Here is some research I did on
> Singletons:
> http://www.oneunified.net/blog/Personal/SoftwareDevelopment/CPP/Singleton.ar
> ticle
> http://www.oneunified.net/blog/Personal/SoftwareDevelopment/CPP/SingletonPer
> Thread.article
>
>
>
_______________________________________________
Larry
I have used Loki stuff too. Under windows, if you're using DLLs though,
you will need some magic incantations to keep from having multiple
copies of the Singleton appear.
Basically, you need to ensure the templates (which contain static data)
get instantiated only once.
Robert Ramey
This is not unique to windows - same issue with linux and I presume
others.
>
> Basically, you need to ensure the templates (which contain static
> data) get instantiated only once.
how do you do this?
Robert Ramey
This is not a Loki mailing list, so I don't want to chew up
tons of bandwidth, but you can look at SingletonDLL
under their distribution for hints.
I've found that there's still some wonky-ness with
Microsoft's compiler, and so I pretty much gave up
on trying to globally fix the issues, and ending up
having actual concrete classes for my factories,
which inside their .cpp implemetation files used
the templated Singletons in an anonymous namespace.
That way, the templates only ever appear in implemetation
files, but not in headers, so I only get one copy.
Maybe someday I'll go back and re-visit the issue,
but the last time I looked into it, I was more interested
in "a solution for Eric's programs" than the "100% correct
solution for everyone's programs".
Thanks Robert, Ray et al for the useful pointers.