Hi all,
I want to summarize a few minor printing related improvements that I have committed over the past few weeks that folks might find useful:
-
formatv() validation: formatv() calls now validate that the replacement field indices start with 0 and are contiguous (no gaps) and that the number of supplied arguments to formatv() match the number of replacement field indices. This ensures that formatv() arguments are neither under not over specified. For cases where this validation is not desired, use the
formatv(false,...)overload. -
formatv() automatic index assignment: formatv() now support not specifying the replacement field indices, in which case they will be auto assigned incrementally. So something like β{0} = {1}.{2}β can become β{}={}.{}β. When using automatic assignment, all fields need to use that, else validation will fail. This should make modifying code that uses formatv() easier as fields are added or removed from the format string.
-
indenthelper for indentation: For code that generates text with indentation, you can now use theindenttype for better ergonomics. It can help code such asOS.indent(4) << "Hello";look a little more streamlined (and clang-formats to better use the space) as such:
OS << indent(4) << "Hello";The
indentstruct supports+/-/++/--operators, as well as scaling when all your indentations are a multiple of a fixed size. Itβs most useful when you can have theindentobject created upront and reuse it multiple times.
Thanks,
Rahul