I've been having trouble with multi-line raw string literals. This small program will illustrate:
using namespace std;
#pragma warning(disable : 1345)
const string grammar = R"!(
<comment> : template = <slash_prefix_comment>
E ::= E '+' T | T
T ::= T '*' F | F
F ::= <number> | '(' E ')'
#pragma warning(default : 1345)
for (auto c: grammar)
cout << c << " " << static_cast<int>(c) << endl;
The pragma is to stop a warning about unterminated string literals. I don't think I should be getting that but I can live with the pragma. The last character to print here should be '$', but with version 14 of the compiler I get a few characters of junk instead of the '$'. With longer literals much more can be cut off. I gather this feature is intended for regex expressions but I'm trying to use it for something like a `here document', which would be longer. I think that should work too. Am I missing something?