我用VC加了BOOST库,可是在用regex_replace时编译老不通过,用regex_match就正常。像网上只用三个参数时一直有错误
如下
D:\程序\MSDev98\MyProjects\TxtEdit\FileInfo.cpp(116) : error C2780: 'OutputIterator __cdecl boost::regex_replace(OutputIterator,Iterator,Iterator,const class boost::reg_expression<charT,traits,Allocator> &,const class std::basic_string<charT,struct 
std::char_traits<charT>,class std::allocator<charT> > &,unsigned long)' : expects 6 arguments - 3 provided
        c:\program files\boost_1_32_0\boost\regex\v4\regex_replace.hpp(46) : see declaration of 'regex_replace'
D:\程序\MSDev98\MyProjects\TxtEdit\FileInfo.cpp(116) : error C2780: 'OutputIterator __cdecl boost::regex_replace(OutputIterator,Iterator,Iterator,const class boost::reg_expression<charT,traits,Allocator> &,const charT *,unsigned long)' : expects 6 a
rguments - 3 provided
        c:\program files\boost_1_32_0\boost\regex\v4\regex_replace.hpp(32) : see declaration of 'regex_replace'多个参数的看不懂,也不好弄
求高手帮忙看看,是哪里出问题了。
顺便请教下关于迭代器的问题,就是其中的Iterator要怎么用?有文章推荐下吗?看boost的文档不是很懂
求指教

解决方案 »

  1.   

    我搜索到了,我的可以用vs2005下        regex reg("(colo)(u)(r)", regex::icase | regex::perl);
    std::string s = "Colour, colour, color, colOurize";
    s = regex_replace(s, reg, "$1$3");运行正常;
    你的库添加对了没?好像有好几个这个库,我也是今天才用这个的,还不很懂。
      

  2.   

    我也遇到同样的问题,不知道为什么。
    包含了#include <boost/regex/mfc.hpp>
    使用boost::tregex和boost::tmatch,用boost::regex_match可以顺利编译并且正确输出但boost::regex_replace的时候却提示错误 3 error C2784: “ATL::CSimpleStringT<B,b> boost::regex_replace(const ATL::CSimpleStringT<B,b> &,const boost::basic_regex<charT,traits> &,const ATL::CSimpleStringT<B,b> &,boost::regex_constants::match_flag_type)”: 无法从“CString”为“const ATL::CSimpleStringT<B,b> &”推导 模板 参数 d:\360data\Documents\Visual Studio 2008\Projects\TEST\TEST\TESTDlg.cpp 466 TEST
    错误 4 error C2784: “ATL::CSimpleStringT<B,b> boost::regex_replace(const ATL::CSimpleStringT<B,b> &,const boost::basic_regex<charT,traits> &,const ATL::CSimpleStringT<B,b> &,boost::regex_constants::match_flag_type)”: 无法从“const wchar_t [1]”为“const ATL::CSimpleStringT<B,b> &”推导 模板 参数 d:\360data\Documents\Visual Studio 2008\Projects\TEST\TEST\TESTDlg.cpp 466 TEST
    错误 5 error C2780: “OutputIterator boost::regex_replace(OutputIterator,BidirectionalIterator,BidirectionalIterator,const boost::basic_regex<charT,traits> &,const ATL::CSimpleStringT<B,b> &,boost::regex_constants::match_flag_type)”: 应输入 6 个参数,却提供了 3 个 d:\360data\Documents\Visual Studio 2008\Projects\TEST\TEST\TESTDlg.cpp 466 TEST
    错误 6 error C2784: “std::basic_string<charT> boost::regex_replace(const std::basic_string<charT> &,const boost::basic_regex<charT,traits> &,Formatter,boost::regex_constants::match_flag_type)”: 无法从“CString”为“const std::basic_string<charT> &”推导 模板 参数 d:\360data\Documents\Visual Studio 2008\Projects\TEST\TEST\TESTDlg.cpp 466 TEST
    错误 7 error C2784: “std::basic_string<charT> boost::regex_replace(const std::basic_string<charT> &,const boost::basic_regex<charT,traits> &,Formatter,boost::regex_constants::match_flag_type)”: 无法从“CString”为“const std::basic_string<charT> &”推导 模板 参数 d:\360data\Documents\Visual Studio 2008\Projects\TEST\TEST\TESTDlg.cpp 466 TEST
    错误 8 error C2780: “OutputIterator boost::regex_replace(OutputIterator,BidirectionalIterator,BidirectionalIterator,const boost::basic_regex<charT,traits> &,Formatter,boost::regex_constants::match_flag_type)”: 应输入 6 个参数,却提供了 3 个 d:\360data\Documents\Visual Studio 2008\Projects\TEST\TEST\TESTDlg.cpp 466 TEST