From 2a747b19e064fdef315c77eb3bdd0c41d47b47b6 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Fri, 25 Jul 2014 08:41:22 -0700 Subject: [PATCH] CheckPtr -> make_ptr (https://github.com/cppformat/cppformat/issues/50) --- format.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/format.h b/format.h index c47db9c3..199150ed 100644 --- a/format.h +++ b/format.h @@ -228,12 +228,12 @@ enum { INLINE_BUFFER_SIZE = 500 }; #if _SECURE_SCL // Use checked iterator to avoid warnings on MSVC. template -inline stdext::checked_array_iterator CheckPtr(T *ptr, std::size_t size) { +inline stdext::checked_array_iterator make_ptr(T *ptr, std::size_t size) { return stdext::checked_array_iterator(ptr, size); } #else template -inline T *CheckPtr(T *ptr, std::size_t) { return ptr; } +inline T *make_ptr(T *ptr, std::size_t) { return ptr; } #endif // A simple array for POD types with the first SIZE elements stored in @@ -259,7 +259,7 @@ class Array { capacity_ = other.capacity_; if (other.ptr_ == other.data_) { ptr_ = data_; - std::copy(other.data_, other.data_ + size_, CheckPtr(data_, capacity_)); + std::copy(other.data_, other.data_ + size_, make_ptr(data_, capacity_)); } else { ptr_ = other.ptr_; // Set pointer to the inline array so that delete is not called @@ -325,7 +325,7 @@ template void Array::grow(std::size_t size) { capacity_ = (std::max)(size, capacity_ + capacity_ / 2); T *p = new T[capacity_]; - std::copy(ptr_, ptr_ + size_, CheckPtr(p, capacity_)); + std::copy(ptr_, ptr_ + size_, make_ptr(p, capacity_)); if (ptr_ != data_) delete [] ptr_; ptr_ = p; @@ -336,7 +336,7 @@ void Array::append(const T *begin, const T *end) { std::ptrdiff_t num_elements = end - begin; if (size_ + num_elements > capacity_) grow(size_ + num_elements); - std::copy(begin, end, CheckPtr(ptr_, capacity_) + size_); + std::copy(begin, end, make_ptr(ptr_, capacity_) + size_); size_ += num_elements; } @@ -1311,7 +1311,7 @@ class BasicWriter { CharPtr GrowBuffer(std::size_t n) { std::size_t size = buffer_.size(); buffer_.resize(size + n); - return internal::CheckPtr(&buffer_[size], n); + return internal::make_ptr(&buffer_[size], n); } // Prepare a buffer for integer formatting.