MCPcopy Create free account
hub / github.com/fmtlib/fmt / append

Function append

include/fmt/base.h:1823–1841  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1821 /// Appends data to the end of the buffer.
1822 template <typename U>
1823 FMT_CONSTEXPR20 void append(const U* begin, const U* end) {
1824 static_assert(std::is_same<T, U>() || std::is_same<U, char>(), "");
1825 while (begin != end) {
1826 auto size = size_;
1827 auto free_cap = capacity_ - size;
1828 auto count = to_unsigned(end - begin);
1829 if (free_cap < count) {
1830 grow_(*this, size + count);
1831 size = size_;
1832 free_cap = capacity_ - size;
1833 count = count < free_cap ? count : free_cap;
1834 }
1835 // A loop is faster than memcpy on small sizes.
1836 T* out = ptr_ + size;
1837 for (size_t i = 0; i < count; ++i) out[i] = static_cast<T>(begin[i]);
1838 size_ += count;
1839 begin += count;
1840 }
1841 }
1842
1843 template <typename Idx> FMT_CONSTEXPR auto operator[](Idx index) -> T& {
1844 return ptr_[index];

Callers

nothing calls this directly

Calls 1

to_unsignedFunction · 0.85

Tested by

no test coverage detected