TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Compile time regular expression in C++

72 点作者 Tideflat超过 1 年前

10 条评论

burntsushi超过 1 年前
I&#x27;d love for someone to add this to rebar[1] so that we can get a good sense of how well it does against other general purpose regex engines. It will be a little tricky to add (since the build step will require emitting a C++ program and compiling it), but it should be possible.<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;BurntSushi&#x2F;rebar">https:&#x2F;&#x2F;github.com&#x2F;BurntSushi&#x2F;rebar</a>
评论 #37515880 未加载
daemin超过 1 年前
It&#x27;s a good library but be careful as it can significantly increase compile times. I added a couple of reasonably long regular expressions to a c++ source file and it increased the compile time from near instant (below to 1 second) to 30 seconds. Might be wise to move these to dedicated source files so you don&#x27;t pay this penalty each time you make changes.
nly超过 1 年前
Boost Xpressive has had static&#x2F;&quot;compile time&quot; regex in C++ since the mid 2000s<p><a href="https:&#x2F;&#x2F;www.boost.org&#x2F;doc&#x2F;libs&#x2F;1_83_0&#x2F;doc&#x2F;html&#x2F;xpressive.html" rel="nofollow noreferrer">https:&#x2F;&#x2F;www.boost.org&#x2F;doc&#x2F;libs&#x2F;1_83_0&#x2F;doc&#x2F;html&#x2F;xpressive.htm...</a><p>A performance comparison would be interesting.
评论 #37517101 未加载
arunc超过 1 年前
D has ctRegex since a decade ago <a href="https:&#x2F;&#x2F;dlang.org&#x2F;phobos&#x2F;std_regex.html#ctRegex" rel="nofollow noreferrer">https:&#x2F;&#x2F;dlang.org&#x2F;phobos&#x2F;std_regex.html#ctRegex</a>
arijun超过 1 年前
At the risk of sounding like an idiot, what is the benefit of being able to match at compile time?
评论 #37516722 未加载
评论 #37516442 未加载
cracauer超过 1 年前
C++ finally catches up to Perl :-)
emmanueloga_超过 1 年前
Since people is posting other lang implementations... someone did it for zig too (probably less polished than this C++ lib) [0]. It is nice that the regexes can be used at compile time too [1].<p>--<p>0: <a href="https:&#x2F;&#x2F;github.com&#x2F;alexnask&#x2F;ctregex.zig">https:&#x2F;&#x2F;github.com&#x2F;alexnask&#x2F;ctregex.zig</a><p>1: I think the difference between C++ template language and Zig comptime is that Zig&#x27;s comptime is almost equal as Zig&#x27;s regular language, whereas the experience of programming C++ templates almost feels like learning a separate, equally complex language.
nemoniac超过 1 年前
This has been available in Lisp since at least 2004.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;edicl&#x2F;cl-ppcre&#x2F;">https:&#x2F;&#x2F;github.com&#x2F;edicl&#x2F;cl-ppcre&#x2F;</a>
评论 #37515190 未加载
评论 #37518507 未加载
评论 #37515167 未加载
docandrew超过 1 年前
This has been a part of the dlang standard library for some time: <a href="https:&#x2F;&#x2F;dlang.org&#x2F;phobos&#x2F;std_regex.html" rel="nofollow noreferrer">https:&#x2F;&#x2F;dlang.org&#x2F;phobos&#x2F;std_regex.html</a>
ape4超过 1 年前
Hopefully the standard regex will be constexpr soon.
评论 #37513457 未加载
评论 #37516916 未加载