I'm trying to write some portable C++ library code that will initially rely on Boost.Regex, and then move to TR1 as compilers support it, and eventually to the C++0x specification after things get moved from the std::tr1 namespace to std. Here is some pseudo-code for what I'd like to do with the preprocessor:
if( exists(regex) ) // check if I can #include <regex>
{
#include <regex> // per TR1
if( is_namespace(std::tr1) ) // are we on TR1 or C++0x?
{
using std::tr1::regex;
} else
{
using std::regex;
}
} else // fall-back to boost
{
#include <boost/regex.hpp>
using boost::regex;
}
Granted, all of that would need to be in preprocessor directives, but if I knew how to accomplish that I wouldn't be asking here. :)