gpt4 book ai didi

c++ - 预编译 .h 文件

转载 作者:搜寻专家 更新时间:2023-10-31 00:22:53 25 4
gpt4 key购买 nike

我有一个用 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;
}

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

最佳答案

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

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com