|
BDE 4.39.x Production Release
|
Provide a formatter customization for floating point types.
Provide a formatter customization for floating point types
floatdoublebsl_format.h
This component provides partial specializations of bsl::formatter catering for floating point types. The component defines a component-private bslfmt::FormatterFloating_Base class that implements the formatters for the float and double types, for both supported output character types (char and wchar_t). Partial specializations are then defined that use bslfmt::FormatterFloating_Base to specify the actual formatters in the bsl namespace. Notice that long double is not one of the supported types (see long double ).
This header is not intended to be included directly. Please include <bsl_format.h> to be able to use specializations of the bsl::formatter for floating point types.
The type long double is rarely used in code as it is not only not guaranteed to provide more precision than double, but in fact it is exactly the same type as double on MSVC (Microsoft Windows), which makes any code that uses it for more precision non-portable.
We also do not have a ryu library implementation for long double so we could only use much slower means of "printing" it than the other two types.
For the above reasons long double is now not supported and an attempt to print it will result in a runtime error.
In this section we show the intended use of this component.
We do not expect most users of bsl::format to interact with this type directly and instead use bsl::format or bsl::vformat, so this example is necessarily unrealistic.
Suppose we want to test pointer formatter's ability to format a number in hexadecimal format with defined alignment and padding.