-
Notifications
You must be signed in to change notification settings - Fork 11
ST::float_formatter
Since string_theory 3.0.
#include <string_theory/format_numeric>| Type | Description |
|---|---|
float_T |
Numeric type for formatting. This must be a floating point type. |
| Name | Summary |
|---|---|
| (constructor) | ST::float_formatter constructor |
| format | Format a floating point value |
| text | Retrieve a pointer to the formatted text |
| size | Retrieve the size of the formatted text |
ST::float_formatter is a helper class for fast conversion of floating point
values to 7-bit ASCII text, analogous to ST::uint_formatter
for unsigned integer types. This is used internally by ST::string,
but the implementation used by ST::format is more sophisticated.
Implementation detail The formatting is currently performed by a call to snprintf with a restricted set of format parameters. For more control over floating point formatting, consider using ST::format instead.
| Signature |
|---|
| float_formatter() noexcept |
Constructs an empty float_formatter.
Since string_theory 3.0.
| Signature |
|---|
| void format(float_T value, char format) noexcept |
Format the specified floating point value into this formatter object's internal buffer.
The only supported format characters are e, f, g, E, F, and G,
which have the same meaning as in snprintf().
Since string_theory 3.0.
| Signature |
|---|
| size_t size() const noexcept |
For float_formatter objects which contain a formatted value, this returns
the number of characters in the formatted text.
Calling size() on an empty float_formatter (i.e. before format()
has been called) is undefined behavior.
Since string_theory 3.0.
See also text()
| Signature |
|---|
| const char *text() const noexcept |
For float_formatter objects which contain a formatted value, this returns
a pointer to the beginning of the formatted text.
Calling text() on an empty float_formatter will return an empty string.
Since string_theory 3.0.
See also size()