Move cstddef include to format.cc and refactor Buffer::append

This commit is contained in:
vitaut 2015-11-13 06:52:13 -08:00
parent 3df9bf3a91
commit 7dcf05108e
2 changed files with 8 additions and 7 deletions

View File

@ -34,6 +34,7 @@
#include <climits>
#include <cmath>
#include <cstdarg>
#include <cstddef> // for std::ptrdiff_t
#if defined(_WIN32) && defined(__MINGW32__)
# include <cstring>
@ -1040,10 +1041,10 @@ void fmt::internal::PrintfFormatter<Char>::format(
ArgConverter<intmax_t>(arg, *s).visit(arg);
break;
case 'z':
ArgConverter<size_t>(arg, *s).visit(arg);
ArgConverter<std::size_t>(arg, *s).visit(arg);
break;
case 't':
ArgConverter<ptrdiff_t>(arg, *s).visit(arg);
ArgConverter<std::ptrdiff_t>(arg, *s).visit(arg);
break;
case 'L':
// printf produces garbage when 'L' is omitted for long double, no

View File

@ -32,7 +32,6 @@
#include <cassert>
#include <cmath>
#include <cstddef> // for std::ptrdiff_t
#include <cstdio>
#include <algorithm>
#include <limits>
@ -484,11 +483,12 @@ class Buffer {
template <typename T>
template <typename U>
void Buffer<T>::append(const U *begin, const U *end) {
std::ptrdiff_t num_elements = end - begin;
if (size_ + num_elements > capacity_)
grow(size_ + num_elements);
assert(begin <= end);
std::size_t new_size = size_ + (end - begin);
if (new_size > capacity_)
grow(new_size);
std::copy(begin, end, internal::make_ptr(ptr_, capacity_) + size_);
size_ += num_elements;
size_ = new_size;
}
namespace internal {