The spate of questions regarding BOOST_FOREACH prompts me to ask users of the Boost library what (if anything) they are doing to prepare their code for portability to the proposed new C++ standard (aka C++0x). For example, do you write code like this if you use shared_ptr:
#ifdef CPPOX #include <memory> #else #include 'boost/shared_ptr.hpp' #endif
There is also the namespace issue – in the future, shared_ptr will be part of the std, namespace – how do you deal with that?
I’m interested in these questions because I’ve decided to bite the bullet and start learning boost seriously, and I’d like to use best practices in my code.
Not exactly a flood of answers – does this mean it’s a non-issue? Anyway, thanks to those that replied; I’m accepting jalfs answer because I like being advised to do nothing!
The simple answer is ‘do nothing’. Boost is not going to remove the libraries that got adopted into 0x. So boost::shared_ptr will still exist. So you don’t need to do anything to maintain portability.
Of course, once 0x is here, a lot of code can be simplified, cleaned up and optimized, but since it’s not yet here, that work can’t really begin. All you can do is make sure your code will still compile when 0x hits… and it should, just like that. Boost isn’t going to delete half their libraries. (I’m not guessing. They’ve stated this on their mailing list before)
(and if you want to switch to the standard shared_ptr, I’d say it’s probably easier to just do a simple search/replace when the time comes. Replace
#include <boost/shared_ptr.hpp>with#include <memory>, andboost::shared_ptrwithstd::shared_ptr)Or of course, you can just decide on the project that you’re going to keep using Boost’s
shared_ptr. Just because it’s been added to the standard library doesn’t mean you have to use it, after all.