How do I implement no-op macro (or template) in C++?

While leaving it blank is the obvious option, I’d go with

#define conditional_noop(x) do {} while(0)

This trick is obviously no-op, but forces you to write a semicolon after conditional_noop(123).

Leave a Comment