GCC 中的 C++0x 正则表达式
以下代码:
#include <regex>
using namespace std;
(snippage)
regex_search(s, m, re);
适用于 Microsoft C++,但 GCC 4.4.3 给出以下错误消息:
/usr/include/c++/4.4/tr1_impl/regex:2255: 警告:内联函数 'bool std::regex_search(_Bi_iter, _Bi_iter, std::match_results<_Bi_iter, _Allocator>&, const std::basic_regex< ;_Ch_type, _Rx_traits>&, std::regex_constants::match_flag_type) [with _Bi_iter = __gnu_cxx::__normal_iterator, std::allocator > >,_Allocator = std::allocator,std::allocator > > > >, _Ch_type = char, _Rx_traits = std::regex_traits]' 使用但从未定义
当然,如果 regex 只是仍在 GCC 待办事项列表中的 C++0x 功能之一,我也不会感到惊讶,但是在这种情况下,我困惑的是,为什么它很乐意接受 include 指令、变量声明等,而只跳过函数调用(它甚至似乎理解)。
我有什么遗漏的吗?
The following code:
#include <regex>
using namespace std;
(snippage)
regex_search(s, m, re);
works in Microsoft C++, but GCC 4.4.3 gives the following error message:
/usr/include/c++/4.4/tr1_impl/regex:2255: warning: inline function ‘bool std::regex_search(_Bi_iter, _Bi_iter, std::match_results<_Bi_iter, _Allocator>&, const std::basic_regex<_Ch_type, _Rx_traits>&, std::regex_constants::match_flag_type) [with _Bi_iter = __gnu_cxx::__normal_iterator, std::allocator > >, _Allocator = std::allocator, std::allocator > > > >, _Ch_type = char, _Rx_traits = std::regex_traits]’ used but never defined
Of course it wouldn't surprise me if regex were simply one of the C++0x features still on the to-do list for GCC, but what I'm scratching my head over is, in that case, why does it happily take the include directive, variable declarations etc. and only trip over the function call (which it even seems to understand).
Is there something I'm missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正则表达式库在 libstdc++ 分支 4.8 之前大多未实现。
不过,4.9 及更高版本确实实现了
。
的实现跟踪器错误The regex library was mostly not implemented in libstdc++ up to branch 4.8.
Versions 4.9 and above do have
<regex>
implemented though.<regex>
对于 g++,使用标志“-std=c++0x”进行编译
For g++, compile with flag "-std=c++0x"