|
|
|
|
|
by makecheck
3127 days ago
|
|
My uses of macros in C++ these days boil down to a few common use cases that are still insanely not handled well by the language: 0. Anything involving file and line number. 1. Generating a string version of something alongside the value of something, without repeating myself. 2. Creating printing macros to keep me from typing out the entire asinine syntax for something like “std::cerr << foo << bar << baz << std::endl” so I only need PRINT(foo << bar << baz). Substituting code fragments is dead simple with a macro and absurdly complex or impossible with other C++ mechanisms. Ironically I’m only doing it because of the poor design of the entire “iostream” stack. |
|