Pages

Saturday, April 29, 2017

Formatting

I/O streams formatting is achieved by more than one framework class working together. At the core are controlling flags, but there are other attributes that can't be described/signaled by a flag, such as the (desired) width of a certain I/O field and how to pad it as necessary. Nevertheless, I'll concentrate on the flags as they form the core.

One the second ISO C++ 11 standard (ISO/IEC 14882-2011(E)), section 27.5.3.1.2, we have the description of the streams formatting flags type, std::ios_base::fmtflags, which builds on a bitmask type (section 17.5.2.13), which is an enumerated type (section 7.2), which is a compound type (section 3.9.2), and so on...

Among other things, this means that, as a bitmask, it has most (if not all) the well-defined bit operations one might expect. But the problem is that this not speak aloud as it should be, which may cause some confusion or obfuscation, resulting in much less than optimal utilization of the feature. This is one is just one out of several other similar situation appearing to establish a mild kind of obscurantism that do not help in getting the most out of the streams framework, which is very nice, flexible and powerful.