Include )" in raw string literal without terminating said literal

后端 未结 3 1809
慢半拍i
慢半拍i 2020-12-24 11:03

The two characters )\" terminate the raw string literal in the example below.
The sequence )\" could appear in my text at some point, and I wa

3条回答
  •  暖寄归人
    2020-12-24 11:40

    Raw string literals let you specify an almost arbitrary* delimiter:

    //choose ### as the delimiter so only )###" ends the string
    R"###(  
        Some Text)"  
    )###";  
    

    *The exact rules are: "any member of the basic source character set except: space, the left parenthesis (, the right parenthesis ), the backslash \, and the control characters representing horizontal tab, vertical tab, form feed, and newline" (N3936 §2.14.5 [lex.string] grammar) and "at most 16 characters" (§2.14.5/2)

提交回复
热议问题