以下代码:
#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&lt; _Bi_iter,_Allocator&gt;&amp;,const std :: basic_regex&lt; ; _Ch_type,_Rx_traits&gt;&amp;,std :: regex_constants :: match_flag_type)[with _Bi_iter = __gnu_cxx :: __ normal_iterator,std :: allocator&gt; &gt;,_ Allocator = std :: allocator,std :: allocator&gt; &GT; &GT; &gt;,_ Ch_type = char,_Rx_traits = std :: regex_traits]'已使用但未定义
当然,如果正则表达式只是GCC待办事项列表中的C ++ 0x功能之一,那也不会让我感到惊讶,但在这种情况下,我正在摸索的是,为什么呢?它很高兴地采用include指令,变量声明等,并且只对函数调用进行跳转(它甚至可以理解)。
我有什么遗失的吗?
答案 0 :(得分:15)
regex库大多没有在libstdc ++中实现,直到分支4.8。
版本4.9及更高版本确实已经实现了<regex>
。
答案 1 :(得分:0)
对于g ++,使用flag&#34; -std = c ++ 0x&#34;
进行编译