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?
A rawstring is a string literal (prefixed with an r) in which the normal escaping rules have been suspended so that everything is a literal.
A raw string in programming allows all characters in a string literal to remain the same in code and in the material, rather than performing their standard programming functions. Raw strings are denoted with the letter r, or capital R, and might look something like this: R “(hello)”
Try
R"(\w\\\w)";
The delimiters […]
were changed to (…)
in n3077.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With