开发者

Pre-compile .h files

开发者 https://www.devze.com 2022-12-29 09:49 出处:网络
I have a really short program written in boost::xpressive #include <iostream> #include <boost/xpressive/xpressive.hpp>

I have a really short program written in 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;
}

It's the Xpressive "hello world". It开发者_运维百科 takes significantly longer than an ordinary hello world to compile. I think it's because the xpressive.hpp file is so huge. Is there a way to pre-compile or pre-process the .hpp file so the compile will be much faster?


You can use precompiled headers if your compiler supports them; both g++ and Visual C++ support precompiled headers, as do most other modern C++ compilers, I suspect.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号