tags:

views:

270

answers:

1

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.research.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?

+6  A: 

Try

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

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

KennyTM
That does it. Thank you.
Rob N