Boost is being actively developed, so each release contains new features and libraries. Some people wish to have libraries that compile for different versions of Boost and also want to use some of the features of the new versions.
Let's take a look at the boost::lexical_cast
change log. According to it, Boost 1.53 has a lexical_cast(const CharType* chars, std::size_t count)
function overload. Our task for this recipe will be to use that function overload for new versions of Boost and work around that missing function overload for older versions.
Well, all we need to do is get info about the version of Boost and use it to write optimal code. This can be done as shown in the following steps:
- We need to include the headers containing the Boost version and
boost::lexical_cast
:
#include <boost/version.hpp> #include <boost/lexical_cast...