mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-30 02:37:36 +02:00
Optimize format string compilation
This commit is contained in:
@ -221,7 +221,12 @@ template <typename Char, typename T, int N> struct field {
|
|||||||
|
|
||||||
template <typename OutputIt, typename... Args>
|
template <typename OutputIt, typename... Args>
|
||||||
constexpr OutputIt format(OutputIt out, const Args&... args) const {
|
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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1486,6 +1486,13 @@ auto copy_str(InputIt begin, InputIt end, appender out) -> appender {
|
|||||||
get_container(out).append(begin, end);
|
get_container(out).append(begin, end);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
template <typename Char, typename InputIt>
|
||||||
|
auto copy_str(InputIt begin, InputIt end,
|
||||||
|
std::back_insert_iterator<std::string> out)
|
||||||
|
-> std::back_insert_iterator<std::string> {
|
||||||
|
get_container(out).append(begin, end);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Char, typename R, typename OutputIt>
|
template <typename Char, typename R, typename OutputIt>
|
||||||
FMT_CONSTEXPR auto copy_str(R&& rng, OutputIt out) -> OutputIt {
|
FMT_CONSTEXPR auto copy_str(R&& rng, OutputIt out) -> OutputIt {
|
||||||
|
Reference in New Issue
Block a user