
25 Jun
2007
25 Jun
'07
4:43 a.m.
"David Abrahams" <dave@boost-consulting.com> wrote in message news:871wg12mia.fsf@grogan.peloton...
#define BOOST_TEST_SINGLETON_INST( inst ) \ namespace { BOOST_JOIN( inst, _t)& inst = BOOST_JOIN( inst, _t)::instance(); }
Here inst ## _t is type of singleton and inst is a reference to the instance
If your question is whether you are allowed to use references inside unnamed namespaces, the answer is yes.
I note that you are still using dynamic initialization above. Using brace-initialization is important to avoid order-of-initialization problems.
I will look into your solution. In my projects it's not usually the problem. If I need to refer to one singleton from different singleton constructor I always use type::instance(). Gennadiy