
Mathias, Thank you for you input. I will certainly use BOOST_THROW_EXCEPTION where possible. However, Singularity provides three distinct advantages over Singleton which I have briefly mentioned in this email, and gone into greater detail in the supporting documentation. Restated differently here, they are: 1) Singleton does not give you control over the lifetime of the object. Your implementation, for example, uses a static instance of the object, which is notorious when there are multiple singletons of this type which depend upon each-other. Controlling initialization and teardown order is famously difficult. Singularity does not suffer from these lifetime issues. 2) Singleton forces global access to the class through the ::instance() member. Sometimes this is what you want, other times it is not. Singularity lets you decide. 3) Singleton encapsulates construction of the object, making it more difficult (not impossible) to pass dependencies into the constructor. Singularity, as a base class, or factory wrapper, exposes all your object's constructors, making Singularity easier to use than Singleton. I hope I have better explained what Singularity brings to the table, above what is arguably, the most well known, and misused design pattern in C++. Thank you, Ben Robinson, Ph.D. On Mon, Aug 22, 2011 at 2:15 PM, Mathias Gaunard < mathias.gaunard@ens-lyon.org> wrote:
On 08/22/2011 09:33 AM, Ben Robinson wrote:
I would like to thank the Boost community for their invaluable feedback
regarding the features and implementation details of Singularity. I have compiled and run Singularity on 4 different compilers: GCC 4.5, MSVC++ 2010, the Texas Instruments CL2000 compiler targeting the 2803x processor, and the Green Hills compiler targeting the Cortex-A8 ARM processor.
If I could give you a few suggestions:
replace calls to throw by BOOST_THROW_EXCEPTION to allow compilation with -fno-exceptions
Another suggestion would be to add support for compilers that support rvalue references but not variadic templates.
Apart from that I'm afraid I don't really see the point of this against
struct my_singleton { private: my_singleton() {} my_singleton(const my_singleton&);
public: static my_singleton& instance() { static my_singleton ins; return ins; } };
which is simple, short, fast to compile, and thread-safe.
______________________________**_________________ Unsubscribe & other changes: http://lists.boost.org/** mailman/listinfo.cgi/boost<http://lists.boost.org/mailman/listinfo.cgi/boost>