31#if UTILITY_MODULE_HAS_STD_FORMAT
33 template<
typename... Args>
34 static std::string
format(
const std::string& format_str, Args&&... args) {
36 return std::vformat(format_str, std::make_format_args(args...));
37 }
catch (
const std::exception&) {
42 template<
typename OutputIt,
typename... Args>
43 static void format_to(OutputIt out,
const std::string& format_str, Args&&... args) {
45 std::vformat_to(out, format_str, std::make_format_args(args...));
46 }
catch (
const std::exception&) {
48 std::copy(format_str.begin(), format_str.end(), out);
54 template<
typename... Args>
55 static std::string
format(
const std::string& format_str, Args&&... args) {
56 std::string result = format_str;
61 template<
typename OutputIt,
typename... Args>
62 static void format_to(OutputIt out,
const std::string& format_str, Args&&... args) {
63 std::string result =
format(format_str, std::forward<Args>(args)...);
64 std::copy(result.begin(), result.end(), out);
69 static std::string
format(
const std::string& format_str) {
74#if !UTILITY_MODULE_HAS_STD_FORMAT
77 auto pos = str.find(
"{}");
78 if (pos == std::string::npos)
return;
80 std::ostringstream oss;
81 oss << std::forward<T>(value);
82 str.replace(pos, 2, oss.str());