使用< tr1/regex>中的regex_replace函数时出现错误 [英] error while using regex_replace function from <tr1/regex>

查看:151
本文介绍了使用< tr1/regex>中的regex_replace函数时出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include <string>
#include <tr1/regex>

#include "TextProcessing.h"

const std::string URL_PATTERN("((http://)[-a-zA-Z0-9@:%_\\+.~#?&//=]+)");
const std::string REPLACEMENT("<a href=\"$&\"\">$&</a>");

std::string textprocessing::processLinks(const std::string & text)
{

    // essentially the same regex as in the previous example, but using a dynamic regex
    std::tr1::regex url(URL_PATTERN);

    // As in Perl, $& is a reference to the sub-string that matched the regex
    return std::tr1::regex_replace(text, url, REPLACEMENT);
}

我正在使用mingw gcc copiler 4.5.0版本.

I'm using mingw gcc copiler 4.5.0 version.

我遇到了以下错误:

%DEV%> mingw32-make all
g++  -Wl,--enable-auto-import -Wall -Wextra -std=c++0x -pedantic -Werror -c  -I./include TextProcessing.cpp
cc1plus.exe: warnings being treated as errors
c:\dev\mingw\bin\../lib/gcc/mingw32/4.5.0/include/c++/tr1_impl/regex:2390:5: error: inline function '_Out_iter std::tr1::regex_replace(_Out_iter, _Bi_iter, _Bi_iter, const std::tr1::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::tr1::regex_constants::match_flag_type) [with _Out_iter = std::back_insert_iterator<std::basic_string<char> >, _Bi_iter = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char> >, _Rx_traits = std::tr1::regex_traits<char>, _Ch_type = char, std::tr1::regex_constants::match_flag_type = std::bitset<11u>]' used but never defined
mingw32-make: *** [TextProcessing.o] Error 1
Process mingw32-make exited with code 2

推荐答案

是的,在我的g ++包含文件中,我还看到regex_replace已声明且未定义.对我来说,它在文件/usr/include/c++/4.4.4/tr1_impl/regex中.声明上方是Doxygen评论部分,其中包括:

Yup, in my g++ include files I also see that regex_replace is declared and not defined. For me, it's in the file /usr/include/c++/4.4.4/tr1_impl/regex . Just above the declaration is a Doxygen comment section which includes:

/** @todo Implement this function. */

这篇关于使用&lt; tr1/regex&gt;中的regex_replace函数时出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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