fork download
  1. static bool process(std::string& macro)
  2. {
  3. if (macro == "error")
  4. {
  5. return false; // fail the parse
  6. }
  7.  
  8. if (macro == "hello")
  9. {
  10. macro = "bye";
  11. }
  12. else if (macro == "bye")
  13. {
  14. macro = "We meet again";
  15. }
  16. else if (macro == "sideeffect")
  17. {
  18. std::cerr << "this is a side effect while parsing\n";
  19. macro = "(done)";
  20. }
  21. else if (std::string::npos != macro.find('~'))
  22. {
  23. std::reverse(macro.begin(), macro.end());
  24. macro.erase(std::remove(macro.begin(), macro.end(), '~'));
  25. }
  26. else
  27. {
  28. macro = std::string("<<") + macro + ">>"; // this makes the unsupported macros appear unchanged
  29. }
  30.  
  31. return true;
  32. }
  33.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1: error: ‘string’ is not a member of ‘std’
prog.cpp:1: error: ‘macro’ was not declared in this scope
prog.cpp:2: error: expected ‘,’ or ‘;’ before ‘{’ token
prog.cpp:1: warning: ‘process’ defined but not used
stdout
Standard output is empty