Optimize format string compilation

This commit is contained in:
Victor Zverovich
2023-06-15 10:28:23 +03:00
parent 6ad301235f
commit 1daae555b3
2 changed files with 13 additions and 1 deletions
+6 -1
View File
@@ -221,7 +221,12 @@ template <typename Char, typename T, int N> struct field {
template <typename OutputIt, typename... Args>
constexpr OutputIt format(OutputIt out, const Args&... args) const {
return write<Char>(out, get_arg_checked<T, N>(args...));
const T& arg = get_arg_checked<T, N>(args...);
if constexpr (std::is_convertible_v<T, basic_string_view<Char>>) {
auto s = basic_string_view<Char>(arg);
return copy_str<Char>(s.begin(), s.end(), out);
}
return write<Char>(out, arg);
}
};