预编译.h文件

Use*_*er1 2 c++ boost compilation xpressive

我有一个用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;
}
Run Code Online (Sandbox Code Playgroud)

这是Xpressive"你好世界".编译需要比普通的hello世界更长的时间.我认为这是因为xpressive.hpp文件非常庞大.有没有办法预编译或预处理.hpp文件,以便编译速度更快?

Jam*_*lis 6

如果编译器支持预编译头,则可以使用预编译头; 这两个G ++VISUAL C++支持预编译头,像大多数其他现代C++编译器,我怀疑.