GCC 中的 C++0x 正则表达式 [英] C++0x regex in GCC

查看:28
本文介绍了GCC 中的 C++0x 正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码:

#include <regex>
using namespace std;

(snippage)

regex_search(s, m, re);

适用于 Microsoft C++,但 GCC 4.4.3 给出以下错误消息:

works in Microsoft C++, but GCC 4.4.3 gives the following error message:

/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]' 使用但从未定义

/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

当然,如果正则表达式只是 GCC 待办事项列表中的 C++0x 特性之一,我也不会感到惊讶,但我正在挠头的是,在这种情况下,为什么它很高兴接受包含指令、变量声明等,并且只跳过函数调用(它甚至似乎理解).

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).

有什么我遗漏的吗?

推荐答案

直到分支 4.8 的 libstdc++ 中大部分都没有实现正则表达式库.

The regex library was mostly not implemented in libstdc++ up to branch 4.8.

4.9 及以上版本确实实现了 .

Versions 4.9 and above do have <regex> implemented though.

  • Implementation tracker bug for <regex>
  • Current library support status for C++11

这篇关于GCC 中的 C++0x 正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆