cppannotations/annotations/yo/first/rawstring.yo

19 lines
1.1 KiB
Text

Standard ASCII-C strings are delimited by double quotes, supporting
hi(escape sequence) escape sequences like tt(\n, \\) and tt(\"). In some
cases it is useful to avoid escaping strings (e.g., in the context of XML). To
this end, bf(C++) offers hi(raw string literal) em(raw string literals).
Raw string literals start with an tt(R), followed by a double quote, followed
by a label (which is an arbitrary sequence of characters not equal to
tt(OPENPAR)), followed by tt(OPENPAR). The raw string ends at the closing
parenthesis tt(CLOSEPAR), followed by the label which is in turn followed by a
double quote. Example:
verb(
R"(A Raw \ "String")"
R"delimiter(Another \ Raw "(String))delimiter"
)
In the first case, everything between tt("OPENPAR) and tt(CLOSEPAR") is
part of the string. Escape sequences aren't supported so the text tt(\ ")
within the first raw string literal defines three characters: a backslash, a
blank character and a double quote. The second example shows a raw string
defined between the markers tt("delimiter+OPENPAR) and tt(CLOSEPARdelimiter").