diff options
author | Devtools Arcadia <[email protected]> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <[email protected]> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /util/stream/labeled.h |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'util/stream/labeled.h')
-rw-r--r-- | util/stream/labeled.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/util/stream/labeled.h b/util/stream/labeled.h new file mode 100644 index 00000000000..2cc539d241d --- /dev/null +++ b/util/stream/labeled.h @@ -0,0 +1,19 @@ +#pragma once + +#include <util/generic/va_args.h> + +/** + * Generates an output sequence for the provided expressions that is formatted + * as a labeled comma-separated list. + * + * Example usage: + * @code + * int a = 1, b = 2, c = 3; + * stream << LabeledOutput(a, b, c, a + b + c); + * // Outputs "a = 1, b = 2, c = 3, a + b + c = 6" + * @endcode + */ +#define LabeledOutput(...) "" Y_PASS_VA_ARGS(Y_MAP_ARGS_WITH_LAST(__LABELED_OUTPUT_NONLAST__, __LABELED_OUTPUT_IMPL__, __VA_ARGS__)) + +#define __LABELED_OUTPUT_IMPL__(x) << #x " = " << (x) +#define __LABELED_OUTPUT_NONLAST__(x) __LABELED_OUTPUT_IMPL__(x) << ", " |