diff --git a/ext/tm/include/tm/string.hpp b/ext/tm/include/tm/string.hpp index 16212cb823..bb270b19b2 100644 --- a/ext/tm/include/tm/string.hpp +++ b/ext/tm/include/tm/string.hpp @@ -1593,9 +1593,9 @@ class String final { * ``` */ template - static String format(const char *const fmt, Args... args) { + static String format(const char *const fmt, Args &&...args) { String out {}; - format(out, fmt, args...); + format(out, fmt, std::forward(args)...); return out; } @@ -1606,24 +1606,24 @@ class String final { } template - static void format(String &out, const char *fmt, T first, Args... rest) { + static void format(String &out, const char *fmt, T &&first, Args &&...rest) { for (const char *c = fmt; *c != 0; c++) { if (*c == '{' && *(c + 1) == 'h' && *(c + 2) == '}') { - if constexpr (std::is_integral_v || std::is_pointer_v) { + if constexpr (std::is_integral_v || std::is_pointer_v>) { out += hex(first, HexFormat::LowercaseAndPrefixed); - format(out, c + 3, rest...); + format(out, c + 3, std::forward(rest)...); return; } else { fprintf(stderr, "String::format: T is not a pointer or an arithmetic type\n"); abort(); } } else if (*c == '{' && *(c + 1) == '}') { - if constexpr (std::is_pointer_v && !std::is_same_v && !std::is_same_v) { + if constexpr (std::is_pointer_v> && !std::is_same_v>> && !std::is_same_v>>) { fprintf(stderr, "String::format: T is a general pointer type but you didn't specify {h}\n"); abort(); } else { - out += first; - format(out, c + 2, rest...); + out += std::forward(first); + format(out, c + 2, std::forward(rest)...); return; } } else {