mirror of
https://github.com/fmtlib/fmt.git
synced 2026-06-15 08:26:13 +08:00
Add FMT_FORMAT_ARGS(fmt, ...) macro to C API to simplify user-defined format wrappers
This commit is contained in:
parent
9afcd929ba
commit
1899aea29f
@ -181,11 +181,14 @@ typedef enum {} fmt_signed_char;
|
||||
(fmt_arg[]) { FMT_MAP(FMT_MAKE_ARG, ##__VA_ARGS__) }
|
||||
# define FMT_EXPAND(v) v
|
||||
|
||||
# define fmt_format(buffer, size, fmt, ...) \
|
||||
fmt_vformat((buffer), (size), (fmt), \
|
||||
FMT_EXPAND(FMT_VA_SELECT(FMT_MAKE_NULL, FMT_MAKE_ARGLIST, \
|
||||
##__VA_ARGS__)(__VA_ARGS__)), \
|
||||
FMT_NARG(, ##__VA_ARGS__))
|
||||
# define FMT_FORMAT_ARGS(fmt, ...) \
|
||||
(fmt), \
|
||||
FMT_EXPAND(FMT_VA_SELECT(FMT_MAKE_NULL, FMT_MAKE_ARGLIST, \
|
||||
##__VA_ARGS__)(__VA_ARGS__)), \
|
||||
FMT_NARG(, ##__VA_ARGS__)
|
||||
|
||||
# define fmt_format(buffer, size, fmt, ...) \
|
||||
fmt_vformat((buffer), (size), FMT_FORMAT_ARGS((fmt), ##__VA_ARGS__))
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user