mirror of
https://github.com/fmtlib/fmt.git
synced 2026-02-12 05:09:59 +08:00
Cleanup documentation
This commit is contained in:
parent
2eda43e9be
commit
83cc5be61a
14
doc/api.md
14
doc/api.md
@ -23,12 +23,12 @@ and macros have prefix `FMT_`.
|
|||||||
## Base API
|
## Base API
|
||||||
|
|
||||||
`fmt/base.h` defines the base API which provides main formatting functions
|
`fmt/base.h` defines the base API which provides main formatting functions
|
||||||
for `char`/UTF-8 with C++20 compile-time checks. It has minimal include
|
for `char`/UTF-8, with C++20 compile-time checks. It has minimal include
|
||||||
dependencies for better compile times. This header is only beneficial when
|
dependencies for better compile times. This header is only beneficial when
|
||||||
using {fmt} as a library (the default) and not in the header-only mode.
|
using {fmt} as a library (the default) and not in the header-only mode.
|
||||||
It also provides `formatter` specializations for the following types:
|
It also provides `formatter` specializations for the following types:
|
||||||
|
|
||||||
- `int`, `long long`,
|
- `int`, `long long`
|
||||||
- `unsigned`, `unsigned long long`
|
- `unsigned`, `unsigned long long`
|
||||||
- `float`, `double`, `long double`
|
- `float`, `double`, `long double`
|
||||||
- `bool`
|
- `bool`
|
||||||
@ -105,8 +105,8 @@ Example ([run](https://godbolt.org/z/nvME4arz8)):
|
|||||||
fmt::print("{}\n", kevin_namespacy::film::se7en); // Output: 7
|
fmt::print("{}\n", kevin_namespacy::film::se7en); // Output: 7
|
||||||
}
|
}
|
||||||
|
|
||||||
Using specialization is more complex but gives you full control over
|
Using a specialization is more complex, but gives you full control over
|
||||||
parsing and formatting. To use this method specialize the `formatter`
|
parsing and formatting. To use this method, specialize the `formatter`
|
||||||
struct template for your type and implement `parse` and `format`
|
struct template for your type and implement `parse` and `format`
|
||||||
methods.
|
methods.
|
||||||
|
|
||||||
@ -194,7 +194,7 @@ In general the formatter has the following form:
|
|||||||
template <> struct fmt::formatter<T> {
|
template <> struct fmt::formatter<T> {
|
||||||
// Parses format specifiers and stores them in the formatter.
|
// Parses format specifiers and stores them in the formatter.
|
||||||
//
|
//
|
||||||
// [ctx.begin(), ctx.end()) is a, possibly empty, character range that
|
// (ctx.begin(), ctx.end()) is a, possibly empty, character range that
|
||||||
// contains a part of the format string starting from the format
|
// contains a part of the format string starting from the format
|
||||||
// specifications to be parsed, e.g. in
|
// specifications to be parsed, e.g. in
|
||||||
//
|
//
|
||||||
@ -515,7 +515,7 @@ chrono-format-specifications).
|
|||||||
|
|
||||||
### Variants
|
### Variants
|
||||||
|
|
||||||
A `std::variant` is only formattable if every variant alternative is
|
A `std::variant` can be formatted only if every alternative is
|
||||||
formattable, and requires the `__cpp_lib_variant` [library
|
formattable, and requires the `__cpp_lib_variant` [library
|
||||||
feature](https://en.cppreference.com/w/cpp/feature_test).
|
feature](https://en.cppreference.com/w/cpp/feature_test).
|
||||||
|
|
||||||
@ -719,7 +719,7 @@ configuring CMake.
|
|||||||
### CMake Options
|
### CMake Options
|
||||||
|
|
||||||
- **`FMT_OS`**: When set to `OFF`, disables OS-specific APIs (`fmt/os.h`).
|
- **`FMT_OS`**: When set to `OFF`, disables OS-specific APIs (`fmt/os.h`).
|
||||||
- **`FMT_UNICODE`**: When set of `OFF`, disables Unicode support on
|
- **`FMT_UNICODE`**: When set to `OFF`, disables Unicode support on
|
||||||
Windows/MSVC. Unicode support is always enabled on other platforms.
|
Windows/MSVC. Unicode support is always enabled on other platforms.
|
||||||
|
|
||||||
### Macros
|
### Macros
|
||||||
|
|||||||
@ -473,7 +473,7 @@ void vprintf(buffer<Char>& buf, basic_string_view<Char> format,
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto arg = get_arg(arg_index);
|
auto arg = get_arg(arg_index);
|
||||||
// For d, i, o, u, x, and X conversion specifiers, if a precision is
|
// For d, i, o, u, x and X conversion specifiers, if a precision is
|
||||||
// specified, the '0' flag is ignored
|
// specified, the '0' flag is ignored
|
||||||
if (specs.precision >= 0 && is_integral_type(arg.type())) {
|
if (specs.precision >= 0 && is_integral_type(arg.type())) {
|
||||||
// Ignore '0' for non-numeric types or if '-' present.
|
// Ignore '0' for non-numeric types or if '-' present.
|
||||||
@ -586,7 +586,7 @@ inline auto vsprintf(basic_string_view<Char> fmt,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats `args` according to specifications in `fmt` and returns the result
|
* Formats `args` according to specifications in `fmt` and returns the result
|
||||||
* as as string.
|
* as string.
|
||||||
*
|
*
|
||||||
* **Example**:
|
* **Example**:
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user