Boost logo

Boost :

Subject: Re: [boost] Breaking existing libraries
From: Roland Schwarz (roland.schwarz_at_[hidden])
Date: 2009-03-14 13:33:00


Matthias Schabel wrote:
> This is a somewhat tangential thought, but ... what if each release of
> the Boost libraries
> was put into its own namespace, so we have code in
>
> namespace boost_1_38_0 { ... }
>
> rather than in namespace boost. Then, in end user code, you just need :
>
> using namespace boost = boost_1_38_0;

David Abrahams wrote:
> It also allows multiple versions of boost to exist in the same
> executable without ODR violations. The ability to configure boost that
> way would be most welcome.

Currently I am on a library project in which I am using boost
internaly, i.e. boost is not visible in the interface of my library.
Since I want my users to

*) use whichever version of boost library they want
*) whil give them the choice to statically link my libs

and

*) not force myself to maintain several version of my lib
   due to dependencies on boost versions

I pursued Matthias Schabels idea. (Altough before I had seen his post.)

I have written a little perl script 'renamespace' that can be
used to rename a namespace identifier for a single file or a whole
project tree. The script is attached to this mail and is
self-documenting. Just execute it with --help option to learn more.

The script has a special short-hand mode to version an entire
boost tree. In addition it modifies two boost files: version.hpp and
config.hpp. The first gets an additional macro BOOST_VERSIONED_NAMESPACE
and the other is modified with a namespace alias (which can be turned
off by the user if needed.) The net result is that it is possible
with no change to the user code to build against this versioned
boost tree.

One caveat: User code that needs to reopen the boost namespace
has to reopen the versioned namespace of course. (This can be automated
with some additional macros in the user code.) One typical case
where this will be necessary is when using the serialization library.

I've put the script under the boost license, so if you think it is
useful I would be glad to contribute it to the tools directory.

-- 
_________________________________________
  _  _  | Roland Schwarz
 |_)(_  | aka. speedsnail
 | \__) | mailto:roland.schwarz_at_[hidden]
________| http://www.blackspace.at





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