c++ 将变参传到非变参函数
#include <fmt/core.h>
#include <iostream>
#include <string>
#include <cstdarg>
template <typename... Args>
void error(const char *format, Args &&...args) {
print_with_format(format, std::forward<Args>(args)...);
}
void print_with_format(const char *format, ...) {
va_list args;
va_start(args, format);
std::string formatted = fmt::vformat(format, fmt::make_args_checked<fmt::arg_join, char>(format, args));
va_end(args);
std::cout << formatted << std::endl;
}
浙公网安备 33010602011771号