None of the other C++ files (eg src/*.cpp) use this construct. Is it needed? Does it work? 

Please look at the other .Rmd files, and the other .cpp files.  The C++ code is actually compiled and not just highlighted.