我有一个用 boost::xpressive 编写的非常短的程序
#include <iostream>
#include <boost/xpressive/xpressive.hpp>
using namespace boost::xpressive;
int main()
{
std::string hello( "hello world!" );
sregex rex = sregex::compile( "(\\w+) (\\w+)!" );
smatch what;
if( regex_match( hello, what, rex ) )
{
std::cout << what[0] << '\n'; // whole match
std::cout << what[1] << '\n'; // first capture
std::cout << what[2] << '\n'; // second capture
}
return 0;
}
这是富有表现力的“hello world”。它的编译时间比普通的 hello world 要长得多。我认为这是因为 xpressive.hpp 文件太大了。有没有办法预编译或预处理 .hpp 文件,以便编译速度更快?
最佳答案
如果您的编译器支持预编译头,您可以使用它们;两者g++和 Visual C++我怀疑,与大多数其他现代 C++ 编译器一样,支持预编译头。
关于c++ - 预编译.h文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2794916/