开发者

How do you use C++0x raw strings with GCC 4.5?

This page says that GCC 4.5 has C++ raw string literals: http://gcc.gnu.org/projects/cxx0x.html

But when I try to use the syntax from this page: http://www2.resea开发者_高级运维rch.att.com/~bs/C++0xFAQ.html#raw-strings

#include <iostream>
#include <string>

using namespace std;

int main()
{
    string s = R"[\w\\\w]";

}

I get this error:

/opt/local/bin/g++-mp-4.5 -std=gnu++0x -O3    rawstr.cc   -o rawstr  
rawstr.cc:9:19: error: invalid character '\' in raw string delimiter  
rawstr.cc:9:5: error: stray 'R' in program

What is the right syntax for raw strings?


Try

R"(\w\\\w)";

The delimiters […] were changed to (…) in n3077.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜