Which one is more appropriate for compile-time configurations (such as debug/release), preprocessor directives, or if constexpr?
#define DBG
#if DBG
// some code
#endif
// --------------------------------- or
inline constexpr bool DEBUG { true };
if constexpr ( DEBUG )
{
// some code
}
Note that, if
if constexpris not part of a template, then the other parts of theif(such as theelses) are still compiled and checked for validity.From cppreference: