|
BDE 4.39.x Production Release
|
Provide a standard compliant format implementation.
Provide a standard compliant format implementation
bsl_format.h
This component will provide, in the bslfmt namespace, compliant implementations of the following free functions exposed by the standard <format> header. These are available for C++03 and later.
Note 1: The overloads taking a locale parameter are not provided. Note 2: Compile-time format string checking is not performed.
This header is not intended to be included directly. Please include <bsl_format.h> to be able to use bsl::format_to_n_result.
User-provided formatters are supported by the BSL implementation, just as they are by the standard library implementation. However, in order for them to be compatible with both implementations, there are specific requirements, notably:
T, do so in the same component header that defines T itself. This avoids issues due to users forgetting to include the header for the formatter.bsl::formatter<T> - DO NOT define std::formatter<T> - Use template arguments for the format context and parse context parameters. This is essential as the parameter type passed in will depend upon underlying implementation.parse function should be constexpr in C++20, but this is not required (and may not be possible) for earlier C++ standards.An example of a user defined formatter is as follows:
This section illustrates the intended use of this component.
| #define BSLFMT_FORMAT_STRING_PARAMETER bslfmt::format_string |
| #define BSLFMT_FORMAT_WSTRING_PARAMETER bslfmt::wformat_string |