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

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

问题描述

以下代码:

  #include< regex> 
使用namespace std;

(snippage)

regex_search(s,m,re);

在Microsoft C ++中可用,但GCC 4.4.3提供以下错误消息:


/ usr / include / c ++ / 4.4 / tr1_impl / regex:2255:warning:内联函数'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但从未定义


当然,如果正则表达式只是GCC待办事项列表中的C ++ 0x特性之一,那么我不会感到惊讶,但是我正在摸索的是,为什么它会很开心采取包括指令,变量声明等,并且只能通过函数调用(它甚至似乎理解)。



有什么我是mi这个正则表达式库大部分没有在libstdc ++中实现,直到4.8分支。


$

解决方案

b $ b

版本4.9及以上的版本确实有< regex> 的实现。


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?

解决方案

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

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

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

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