c++ - 预编译.h文件

标签 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;
}

这是富有表现力的“hello world”。它的编译时间比普通的 hello world 要长得多。我认为这是因为 xpressive.hpp 文件太大了。有没有办法预编译或预处理 .hpp 文件,以便编译速度更快?

最佳答案

如果您的编译器支持预编译头,您可以使用它们;两者g++Visual C++我怀疑,与大多数其他现代 C++ 编译器一样,支持预编译头。

关于c++ - 预编译.h文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2794916/

相关文章:

c++ - 使用信号处理程序触发事件时,如何让 boost.msm 正确更改状态?

c++ - 为什么 Visual Studio 会生成这些附加文件?

c# - 当我在 .net 框架中将源代码编译为 exe 文件时会发生什么

c++ - 在 Unix C++ 中列出文件夹根目录中的文件和目录

c++ - 文件夹不存在则创建,存在则不做任何操作

c++ - C++中命名空间的一个例子

c++ - boost::iostreams::stream<boost::iostreams::array_source> 不设置 EOF

c++ - 为 boost::iterator_adapter 设置 iterator_bracket_proxy

java - 在不同包的子类中使用 super() 作为 equals()

c++ - QTableWidget 在不处于焦点时挂起/暂停