c++ - 将 tr1::regex 与 unicode 字符串一起使用时出现问题

标签 c++ regex compiler-errors tr1

    std::wstring str(L"something");
    std::tr1::wregex rx(L"something");
    std::tr1::wcmatch res;
    std::tr1::regex_search(str, res, rx);       

编译失败,错误:

error C2784: 'bool std::tr1::regex_search(const std::basic_string<_Elem,_StTraits,_StAlloc> &,const std::tr1::basic_regex<_Elem,_RxTraits> &,std::tr1::regex_constants::match_flag_type)' : could not deduce template argument for 'const std::tr1::basic_regex<_Elem,_RxTraits> &' from 'std::tr1::wcmatch'

最佳答案

您应该使用 wsmatch,它用于 wstring 迭代器,而不是 wcmatch,它用于 wchar_t*.

关于c++ - 将 tr1::regex 与 unicode 字符串一起使用时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6980522/

相关文章:

C编程中的编译器错误 "void value not ignored as it ought to be"

c++ - 从 NumericVector 填充 C++ 数组的更好习惯用法

swift - 类型 '[Users]'的值没有成员 'username'

C++ : What's the easiest library to open video file

javascript - 如何提取字符串中 url 后面的文本?

java - 使用 lambda 表达式和正则表达式 java 返回具有文件大小的映射

javascript - 正则表达式 (JS) — 匹配任何 5 个字符的组合,但忽略 5 个字符的重复

java - 用户定义方法java的问题

c++ - 有没有 C++ 引用手册 C :a reference manual?

c++ - 在 OSX 上通过 dlopen 打开库时调试崩溃