【发布时间】:2010-11-13 23:25:36
【问题描述】:
我正在尝试编写一些可移植的 C++ 库代码,这些代码最初将依赖于 Boost.Regex,然后在编译器支持时移至 TR1,并在事情从 std 移出后最终移至 C++0x 规范: :tr1 命名空间到标准。这是我想用预处理器做的一些伪代码:
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;
}
当然,所有这些都需要在预处理器指令中,但如果我知道如何完成,我就不会在这里问了。 :)
【问题讨论】:
标签: c++ c++11 boost c-preprocessor tr1