Created
March 30, 2023 14:58
-
-
Save FreeBirdLjj/176927072693962942906e666747551f to your computer and use it in GitHub Desktop.
A useful macro to simulate a REPL in C++.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#define REPL(expr) std::cout << "> " << #expr << std::endl << (expr) << std::endl | |
int main() | |
{ | |
int a = 1, b = 2; | |
REPL(a + b); | |
// print out: | |
// > a + b | |
// 3 | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment