Boost logo

Boost :

Subject: [boost] version conflicts: is there a solution?
From: Lewis Hyatt (lhyatt_at_[hidden])
Date: 2009-06-23 20:49:12


Hi Everyone-

This has been discussed before
(http://thread.gmane.org/gmane.comp.lib.boost.devel/180008), but I think my
question is along a slightly different line so I thought I would ask about it.
Let's say I want to compile and distribute a library (without the source), and I
happen to use some boost header-only libraries as an implementation detail in
some of my functions. None of the headers associated with my library include
boost headers; it's purely an internal detail.

Now, it seems to me that users of my library will still have to be aware of the
fact that I used boost in my implementation -- specifically, if they happen to
use different versions of the same boost libraries in their code, then the ODR
is violated and the behavior is undefined.

I realize this isn't a boost-specific problem (it would affect any library of
template functions), but I am wondering if there is a boost-specific solution
already worked out? Has anyone thought about this? It seems to me that in this
case, what would be ideal would be if I could do:

#define BOOST_NAMESPACE some_unique_namespace_for_boost
#include "boost/algorithm/string.hpp"
BOOST_NAMESPACE::shared_ptr<void> x; //or whatever

Then I can insure there are no ODR violations and I don't need to bother users
of my library with the fact that I used boost at all.

Other than the sheer annoyance of having to go through all the boost code to use
this macro, is there a strong downside to this approach?

Alternatively, I could try:

namespace {
    #include "boost/..."
}

But I don't know, could this work? Or are there boost headers that rely on fully
qualified references like ::boost::algorithm::whatever?

I'd appreciate anyone's thoughts on this issue, thanks!

-Lewis


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