AK: Add outln_if and warnln_if

This uses the same gating mechanism as dbgln_if and should be equivalent
to #define flag etc
This commit is contained in:
Hendiadyoin1 2021-04-15 22:06:18 +02:00 committed by Linus Groh
parent 2976311536
commit 2e11b2d35a
Notes: sideshowbarker 2024-07-18 20:15:23 +09:00

View file

@ -384,13 +384,29 @@ void outln(CheckedFormatString<Parameters...>&& fmtstr, const Parameters&... par
inline void outln() { outln(stdout); }
# define outln_if(flag, fmt, ...) \
do { \
if constexpr (flag) \
outln(fmt, ##__VA_ARGS__); \
} while (0)
template<typename... Parameters>
void warn(CheckedFormatString<Parameters...>&& fmtstr, const Parameters&... parameters) { out(stderr, move(fmtstr), parameters...); }
void warn(CheckedFormatString<Parameters...>&& fmtstr, const Parameters&... parameters)
{
out(stderr, move(fmtstr), parameters...);
}
template<typename... Parameters>
void warnln(CheckedFormatString<Parameters...>&& fmtstr, const Parameters&... parameters) { outln(stderr, move(fmtstr), parameters...); }
inline void warnln() { outln(stderr); }
# define warnln_if(flag, fmt, ...) \
do { \
if constexpr (flag) \
outln(fmt, ##__VA_ARGS__); \
} while (0)
#endif
void vdbgln(StringView fmtstr, TypeErasedFormatParams);