From Phases of translation, backslash joining next line happens in Phase 2 and string literal evaluation happens in Phase 3. Then why does the following code does string evaluation before?
#include<string>
#include<iostream>
int main() {
std::string s = R"(before\
after)";
std::cout << s;
}
gives:
before\
after
instead of:
beforeafter
Phase 2
- Whenever backslash appears at the end of a line (immediately followed by zero or more whitespace characters other than new-line followed by (since C++23) the newline character), these characters are deleted, combining two physical source lines into one logical source line. [...]
Phase 3
- The source file is decomposed into comments, sequences of whitespace characters (space, horizontal tab, new-line, vertical tab, and form-feed), and preprocessing tokens, which are the following: a) header names such as or "myfile.h" b) identifiers c) preprocessing numbers d) character and string literals , including user-defined (since C++11) [...]