Precompile .h files

I have a very 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;
}

      

This is Xpressive "hello world". It takes significantly longer to compile than the normal hello world. I think because the xpressive.hpp file is so huge. Is there a way to pre-compile or preprocess the .hpp file so that compilation is much faster?

+2


a source to share


1 answer


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



+6


a source







All Articles