|
| VLINK_EXPORT size_t | vlink::format::detail::format_uint_to (char *buf, unsigned value) noexcept |
| |
| VLINK_EXPORT size_t | vlink::format::detail::format_int_to (char *buf, int value) noexcept |
| |
| VLINK_EXPORT size_t | vlink::format::detail::format_ulong_long_to (char *buf, unsigned long long value) noexcept |
| |
| VLINK_EXPORT size_t | vlink::format::detail::format_long_long_to (char *buf, long long value) noexcept |
| |
| VLINK_EXPORT size_t | vlink::format::detail::format_pointer_to (char *buf, const void *ptr) noexcept |
| |
| VLINK_EXPORT size_t | vlink::format::detail::format_float_to (char *buf, size_t buflen, float value) noexcept |
| |
| VLINK_EXPORT size_t | vlink::format::detail::format_double_to (char *buf, size_t buflen, double value) noexcept |
| |
| template<typename... ArgsT> |
| detail::FormatArgStore< char, detail::RemoveCvref< ArgsT >... > | vlink::format::make_format_args (const ArgsT &... args) |
| | Public API 更多...
|
| |
| template<typename... ArgsT> |
| FormatToNResult< char * > | vlink::format::format_to_n (char *out, size_t n, format_string< ArgsT... > fmt, const ArgsT &... args) |
| | Formats args into out, writing at most n characters. 更多...
|
| |
| template<size_t NumT, typename... ArgsT> |
| FormatToResult | vlink::format::format_to (char(&out)[NumT], format_string< ArgsT... > fmt, const ArgsT &... args) |
| | Formats args into a fixed-size character array; equivalent to format_to_n. 更多...
|
| |
| template<typename OutputItT , typename... ArgsT, std::enable_if_t< detail::kIsOutputIterator< detail::RemoveCvref< OutputItT >> &&!std::is_array_v< std::remove_reference_t< OutputItT >>, int > = 0> |
| detail::RemoveCvref< OutputItT > | vlink::format::format_to (OutputItT &&out, format_string< ArgsT... > fmt, const ArgsT &... args) |
| | Formats args through an output iterator. 更多...
|
| |
Minimal heap-free {} placeholder formatter for the logger hot path.
VLink targets C++17 first; std::format is unavailable on that baseline and far heavier on older standards. This header provides a focused subset of std::format-style formatting that writes through a stack-allocated buffer or a user-supplied output iterator, never allocates, and dispatches via a compile-time type tag rather than a virtual call chain.
- Supported argument types
| C++ type | Format token | Example output |
signed char / short / int | {} | 42 |
unsigned char / ... | {} | 42 |
long / long long | {} | 123456789 |
unsigned long / long long | {} | 123456789 |
bool | {} | true / false |
char | {} | A |
float / double | {} | 3.14 |
const char* / char* | {} | hello |
std::string / std::string_view | {} | hello |
T* (any pointer) | {} | 0x7ffe1234 |
enum | {} | underlying integer |
- Placeholder syntax
| Token | Meaning |
{} | Consume the next argument in order |
{0}, {1}, ... | Explicit positional index |
{{ / }} | Literal opening / closing brace |
- Public API
| Function | Output target | Truncation flag |
format_to_n(out, n, fmt, ...) | char* buffer with cap n | yes |
format_to(out[N], fmt, ...) | Fixed-size array | yes |
format_to(it, fmt, ...) | Output iterator | no |
- Example
char buf[128];
buf[result.size] = '\0';
- 注解
- Floats and doubles use
"%g" via snprintf; there is no precision modifier in the placeholder syntax. Unsupported argument types trigger a compile-time static_assert.