hi,
Google results say there are more than 1 singleton template/baseclass in boost, which one do you suggest?
Can anyone give me a clue?
Thanks
hi,
Google results say there are more than 1 singleton template/baseclass in boost, which one do you suggest?
Can anyone give me a clue?
Thanks
My version of boost has following singleton.hpp headers:
C:\boost_1_38_0\boost\pool\detail\singleton.hpp
C:\boost_1_38_0\boost\serialization\singleton.hpp
C:\boost_1_38_0\boost\thread\detail\singleton.hpp
I haven't used any of those, but I'd probably stay away from the ones in detail directories.
Anyway, http://torjo.com/tobias/index.html#boost_utility_singleton.reference.singleton looks like one to use, but it doesn't seem to be really a part of boost (not accepted yet?).
You shouldn't use the singletons in boost, they are for internal purpose only (see the "detail" folders of separate libes). That's why you don't have a Singleton library (yet) exposed on the boost website.
A singleton class is very simple to implement but there are many variants that are useful in specific cases so you should use something that fit what you think a singleton should behave like.
Now, there is other libraries providing singleton, the most generic being Loki. But it could blow your mind ;)