开发者

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

开发者 https://www.devze.com 2023-01-02 21:55 出处:网络
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++0xFA

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

精彩评论

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