I wrote something similar a couple years ago, except my macro automatically compiled to a no op if compiled in release mode, which is very convenient for switching back-and-forth to the testing.
> The dbg! macro works exactly the same in release builds. This is useful when debugging issues that only occur in release builds or when debugging in release mode is significantly faster.
Note, however, that the C++ dbg(..) macro can be easily disabled to a no-op (identity-op, to be precise) with the DBG_MACRO_DISABLE flag.