
Kowalke Oliver (QD IT PA AS) wrote:
Hi Tobias, how does Boost.Utility/Singleton solve the problem if the singleton calss itself needs arguments in its ctor (for instance if I want to use the RAII pattern)?
Not at all, you have to solve it yourself. So reading from you post you have a class you can't (or don't want to) change, that needs arguments in the ctor. You can make a Singleton from that class using multiple inheritance. class a_singleton : public boost::singleton< a_singleton >, public my_class { a_singleton(boost::restricted) : my_class( /* args go here */ ) { } }; Parameterizing the static 'instance' method of a classic Singleton take is a bad idea IMO, because it causes redundancy all over the place. Regards, Tobias