[patch] using boost/version.hpp

Dear Boosters, I am trying to keep some backward compatibility (for some while) for the boost libraries we use in our codes (ublas for example), and I find that the addition below to boost/version.hpp helps a lot with readability in the code instead of using // BOOST_VERSION % 100 is the sub-minor version // BOOST_VERSION / 100 % 1000 is the minor version // BOOST_VERSION / 100000 is the major version ------------------- define BOOST_VERSION_MAJOR 1 #define BOOST_VERSION_MINOR 33 #define BOOST_VERSION_SUBMINOR 1 #define BOOST_MAKE_VERSION( a,b,c ) ((a)*100000+(b)*100+(c)) #define BOOST_VERSION \ BOOST_MAKE_VERSION(BOOST_VERSION_MAJOR,BOOST_VERSION_MINOR,BOOST_VERSION_SUBMINOR) #define BOOST_IS_VERSION(a,b,c) ( BOOST_VERSION >= BOOST_MAKE_VERSION(a,b,c) ) ---------------------------- In order to test the current version of boost: #if BOOST_IS_VERSION(1,33,0) ... write the code according to the API >= 1.33.0 #else ... write the code according to the API < 1.33.0 #endif would that be of interest ? Best regards C.

Christophe Prud'homme wrote:
Dear Boosters,
I am trying to keep some backward compatibility (for some while) for the boost libraries we use in our codes (ublas for example), and I find that the addition below to boost/version.hpp helps a lot with readability in the code instead of using
// BOOST_VERSION % 100 is the sub-minor version // BOOST_VERSION / 100 % 1000 is the minor version // BOOST_VERSION / 100000 is the major version
There's been some recent discussions related to version numbers from the proposal/summary I posted for normalizing version checking which is related: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?BoostConfig It has a BOOST_VERSION_NUMBER macro like your BOOST_MAKE_VERSION macro. That type of macro can already be used with the BOOST_WORKAROUND utility. For example...
In order to test the current version of boost: #if BOOST_IS_VERSION(1,33,0) ... write the code according to the API >= 1.33.0 #else ... write the code according to the API < 1.33.0 #endif
#if BOOST_WORKAROUND( BOOST_VERSION, >= BOOST_VERSION_NUMBER(1,33,0) ) ... #else ... #endif The discussions also mentioned changing BOOST_WORKAROUND to allow this: #if BOOST_WORKAROUND( BOOST_VERSION,>=,1,33,0 ) -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim - Grafik/jabber.org

| There's been some recent discussions related to version numbers from the | proposal/summary I posted for normalizing version checking which is | related: *blush* I should have looked into my boost mailbox and post on the thread, sorry. | http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?BoostConfig Good. I am all for this kind of proposal. | It has a BOOST_VERSION_NUMBER macro like your BOOST_MAKE_VERSION macro. | That type of macro can already be used with the BOOST_WORKAROUND | utility. For example... | > In order to test the current version of boost: | > #if BOOST_IS_VERSION(1,33,0) | > ... write the code according to the API >= 1.33.0 | > #else | > ... write the code according to the API < 1.33.0 | > #endif | | #if BOOST_WORKAROUND( BOOST_VERSION, >= BOOST_VERSION_NUMBER(1,33,0) ) it is a bit wordy to just check for a version number, I think I find BOOST_IS_VERSION above more concise | ... | #else | ... | #endif | | The discussions also mentioned changing BOOST_WORKAROUND to allow this: | | #if BOOST_WORKAROUND( BOOST_VERSION,>=,1,33,0 ) Yup why not. Thanks for bringing this up and sorry for not reading properly my boost emails cu C. -- MIT Affiliate Debian/GNU/Linux developer for scientific computing packages fingerprint = 3703 50DE 7A9F 024E 0F26 0D07 A18F B40B D4BE 1450

"Christophe Prud'homme" <prudhomm@mit.edu> wrote in message news:200510202250.43836.prudhomm@mit.edu...
[snip]
| It has a BOOST_VERSION_NUMBER macro like your BOOST_MAKE_VERSION macro. | That type of macro can already be used with the BOOST_WORKAROUND | utility. For example... | > In order to test the current version of boost: | > #if BOOST_IS_VERSION(1,33,0) | > ... write the code according to the API >= 1.33.0 | > #else | > ... write the code according to the API < 1.33.0 | > #endif | | #if BOOST_WORKAROUND( BOOST_VERSION, >= BOOST_VERSION_NUMBER(1,33,0) ) it is a bit wordy to just check for a version number, I think I find BOOST_IS_VERSION above more concise
IMHO, BOOST_IS_VERSION suggests that the version is _exactly_ 1.33.0. // Johan
participants (3)
-
Christophe Prud'homme
-
Johan Nilsson
-
Rene Rivera