I am trying to write some portable C ++ library code that will initially rely on Boost.Regex, and then move to TR1 when compilers support it, and eventually to the C ++ 0x specification after everything has been ported from std :: tr1 namespace to std. Here is some kind of pseudo code for what I would like to do with the preprocessor:
if( exists(regex) )
{
#include <regex> // per TR1
if( is_namespace(std::tr1) )
{
using std::tr1::regex;
} else
{
using std::regex;
}
} else
{
#include <boost/regex.hpp>
using boost::regex;
}
Of course, all this should be in the preprocessor directives, but if I knew how to do this, I would not ask here. :)
source
share