Boost logo

Boost :

Subject: [boost] [predef] Suggestion for Boost itself to start using this.
From: Fletcher, John P (j.p.fletcher_at_[hidden])
Date: 2014-01-25 12:41:24


I have started to use the Boost predef library. I think it will be a good idea for this to be used within Boost. This is actually contained in the Future Work section of the Boost predef manual.

http://www.boost.org/doc/libs/1_55_0/libs/predef/doc/html/predef/introduction.html

* And obviously there's lots of work to do in reformulating the existing Boost libraries to use the Predef library once it's accepted.

I have been attempting to make use of it and one of the problems is that BOOST_VERSION itself is not consistent with it. It would I think break a lot of existing code to change BOOST_VERSION. Instead I suggest having another define a longside it which is consistent with Boost predef.

I wnt to make the following suggestions to go into the definition of the version.

First check that the version of Boost is recent enough. 1.55.0 is the first to have Boost predef.

#include <boost/version.hpp>
#if BOOST_VERSION >= 105500
#include <boost/predef.h>
#define BOOST_HAVE_BOOST_PREDEF
#endif
#include <iostream>
#include <string>
#include <sstream>

Then if that is true then construct a new defintion:

#ifdef BOOST_HAVE_BOOST_PREDEF
#ifdef BOOST_VERSION
// The following translates BOOST_VERSION to a BOOST_VERSION_NUMBER!!
// BOOST_VERSION % 100 is the patch level
// BOOST_VERSION / 100 % 1000 is the minor version
// BOOST_VERSION / 100000 is the major version
   #define BV BOOST_VERSION
   #define BVN BOOST_VERSION_NUMBER(BV / 100000,BV / 100 % 1000,BV %100)
   #define BOOST_VERSION_VERSION BVN
   #undef BVN
   #undef BV
#endif

Other libraries can also construct new version codes.

John Fletcher


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