Boost logo

Boost :

From: Gennadiy Rozental (gennadiy.rozental_at_[hidden])
Date: 2005-06-21 00:43:14


"David Abrahams" <dave_at_[hidden]> wrote in message
news:u1x6xgong.fsf_at_boost-consulting.com...
>
> I just tried to compile something with the test library and two
> translation units. Boom! It was this definition, which appears in
> boost/test/impl/execution_monitor.ipp.

I wonder which Boost.Test componenent were you using?

> signal_handler* signal_handler::s_active_handler = NULL; //!! need to be
> placed in thread
> specific storage

I would prefer to fix this post release.

> have this problem. The answer is to initialize a *reference* in the
> unnamed namespace to a single, common object:
>
> namespace whatever
> {
> class foo {};
>
> template <class T, int = 0>
> struct unique_instance
> {
> T& get()
> {
> static T x;
> return x;
> };
> };
>
> namespace
> {
> foo& bar = unique_instance<foo>::get();
> }
> }

This is an idiom I am using in Boost.Test's trivial_singleton.hpp.

Here is a solution for the issue above:

=====================================
struct active_signal_handler_t : public singleton<active_signal_handler_t> {
    signal_handler* _;
private:
    BOOST_TEST_SINGLETON_CONS( active_signal_handler_t );
};

BOOST_TEST_SINGLETON_INST( active_signal_handler )
=====================================

active_signal_handler._ is s_active_handler above.

Gennadiy


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk