Boost logo

Boost :

From: Steven Watanabe (steven_at_[hidden])
Date: 2007-02-12 20:28:52


AMDG

All the static const objects in the library cause ODR
violations for functions that use them. You can avoid
this by only putting a reference in the unnamed namespace.

#define BOOST_UNITS_STATIC_CONSTANT(type, name) \
    template<bool> struct name##_intance_t { \
        static const type instance; \
    }; \
    namespace { \
        const type& name(name##_intance_t<true>::instance);\
    } \
    template<bool b> \
    type name##_intance_t<b>::instance

BOOST_UNITS_STATIC_CONSTANT(energy, joule);
BOOST_UNITS_STATIC_CONSTANT(typeof(1.0*meters/second) , c) =
299792458*meters/second;

In Christ,
Steven Watanabe


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