Boost logo

Boost :

From: Jonathan Biggar (jon_at_[hidden])
Date: 2008-04-27 17:24:48


I noticed some discussion in threads about the worries that some people
have with linking their application against boost and then needing a
third party library that also links to a potentially different version
of boost that might not be available to the in source form.

Has any thought been given to changing the boost namespace declaration
to include the version number, like this:

namespace boost_1_35_0 {
        // boost libraries declared here
};

#ifndef BOOST_NAMESPACE_ALIAS_DECLARED
#define BOOST_NAMESPACE_ALIAS_DECLARED

namespace boost = boost_1_35_0;

#endif // BOOST_NAMESPACE_ALIAS_DECLARED

This allows an application linked to boost 1.X+1.0 to also link to a
third party library that privately uses boost 1.X.0 without causing ODR
problems. Of course it doesn't help if the third party library exposes
boost types in its interface.

We could even go further and add another wrapper around the
#ifndef/#endif above like this:

#ifndef BOOST_NAKED_NAMESPACE
#ifndef BOOST_NAMESPACE_ALIAS_DECLARED
#define BOOST_NAMESPACE_ALIAS_DECLARED

namespace boost = boost_1_35_0;

#endif // BOOST_NAMESPACE_ALIAS_DECLARED
#endif // BOOST_NAKED_NAMESPACE

This allows an application to #define BOOST_NAKED_NAMESPACE and then use
the versioned boost namespace directly. With care, it would be possible
to write an application that used two versions of boost simultaneously,
for example if that mythical third party library *did* expose boost
types in its interface...

-- 
Jon Biggar
Floorboard Software
jon_at_[hidden]
jon_at_[hidden]

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