std::regex with char32_t in microsoft visual studio?

std::regex with char32_t in microsoft visual studio?

本文关键字:microsoft visual in studio regex with char32 std      更新时间:2023-10-16

我想知道为什么这不是工作-如果这是一个简单的问题从VS 2010;

std::basic_regex<char32_t> re;

上面这行给出了一个编译错误:

1>c:program filesmicrosoft visual studio 10.0vcincluderegex(1975): error C2027: use of undefined type 'std::tr1::regex_traits<_Elem>'
1>          with
1>          [
1>              _Elem=char32_t
1>          ]

还有很多后续错误,都在同一行。所以这是一个特定于visual studio 2010的问题-是否有一个解决方案(除了首先将字符串转换为UTF8并使用它作为基础,然后重新转换回UTF32)。

和/或我应该使用boost::regex,我将绕过这个问题吗?

您很可能需要使用Boost。带ICU的正则表达式

例子:icu_example.cpp

或者,如果你在Windows上,MFC: mfc_example.cpp