detail::write in one more place relevant to printf with long arguments, requires moving the definition of detail::write up in the file

This commit is contained in:
rimathia 2020-11-12 15:52:39 +01:00
parent 986fa00406
commit 0f5155bcde

View File

@ -638,6 +638,7 @@ void iterator_buffer<OutputIt, T, Traits>::flush() {
out_ = copy_str<T>(data_, data_ + this->limit(this->size()), out_);
this->clear();
}
} // namespace detail
// The number of characters to store in the basic_memory_buffer object itself
@ -1518,6 +1519,34 @@ FMT_NOINLINE OutputIt fill(OutputIt it, size_t n, const fill_t<Char>& fill) {
return it;
}
template <typename Char, typename OutputIt>
OutputIt write(OutputIt out, monostate) {
FMT_ASSERT(false, "");
return out;
}
template <typename Char, typename OutputIt,
FMT_ENABLE_IF(!std::is_same<Char, char>::value)>
OutputIt write(OutputIt out, string_view value) {
auto it = reserve(out, value.size());
it = copy_str<Char>(value.begin(), value.end(), it);
return base_iterator(out, it);
}
template <typename Char, typename OutputIt>
OutputIt write(OutputIt out, basic_string_view<Char> value) {
auto it = reserve(out, value.size());
it = copy_str<Char>(value.begin(), value.end(), it);
return base_iterator(out, it);
}
template <typename Char>
buffer_appender<Char> write(buffer_appender<Char> out,
basic_string_view<Char> value) {
get_container(out).append(value.begin(), value.end());
return out;
}
// Writes the output of f, padded according to format specifications in specs.
// size: output size in code units.
// width: output display width in (terminal) column positions.
@ -1607,7 +1636,7 @@ OutputIt write(OutputIt out, basic_string_view<StrChar> s,
: 0;
using iterator = remove_reference_t<decltype(reserve(out, 0))>;
return write_padded(out, specs, size, width, [=](iterator it) {
return copy_str<Char>(data, data + size, it);
return detail::write<Char>(it, basic_string_view<StrChar>(data, size));
});
}
@ -2034,34 +2063,6 @@ template <typename T> struct is_integral : std::is_integral<T> {};
template <> struct is_integral<int128_t> : std::true_type {};
template <> struct is_integral<uint128_t> : std::true_type {};
template <typename Char, typename OutputIt>
OutputIt write(OutputIt out, monostate) {
FMT_ASSERT(false, "");
return out;
}
template <typename Char, typename OutputIt,
FMT_ENABLE_IF(!std::is_same<Char, char>::value)>
OutputIt write(OutputIt out, string_view value) {
auto it = reserve(out, value.size());
it = copy_str<Char>(value.begin(), value.end(), it);
return base_iterator(out, it);
}
template <typename Char, typename OutputIt>
OutputIt write(OutputIt out, basic_string_view<Char> value) {
auto it = reserve(out, value.size());
it = copy_str<Char>(value.begin(), value.end(), it);
return base_iterator(out, it);
}
template <typename Char>
buffer_appender<Char> write(buffer_appender<Char> out,
basic_string_view<Char> value) {
get_container(out).append(value.begin(), value.end());
return out;
}
template <typename Char, typename OutputIt, typename T,
FMT_ENABLE_IF(is_integral<T>::value &&
!std::is_same<T, bool>::value &&