From ea8013af74844e91db17d26dae4b24c1a5ddd76c Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Wed, 5 Jun 2019 19:21:06 +0200 Subject: Use inplace new instead of std::_Construct Use std::destroy or std::destroy_at instead of std::_Destroy. --- vespalib/src/vespa/vespalib/util/array.h | 6 +++--- vespalib/src/vespa/vespalib/util/array.hpp | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/vespalib/src/vespa/vespalib/util/array.h b/vespalib/src/vespa/vespalib/util/array.h index 23ce250642b..ef39b449a45 100644 --- a/vespalib/src/vespa/vespalib/util/array.h +++ b/vespalib/src/vespa/vespalib/util/array.h @@ -107,14 +107,14 @@ public: * Returns true if it was possible to unreserve memory, false if not. */ bool try_unreserve(size_t n); - void push_back(const T & v) { std::_Construct(push_back(), v); } + void push_back(const T & v) { ::new (static_cast(push_back())) T(v); } iterator push_back() { extend(size()+1); return array(_sz++); } iterator push_back_fast() { return array(_sz++); } void push_back_fast(const T & v) { *array(_sz++) = v; } void pop_back() { _sz--; - std::_Destroy(array(_sz)); + std::destroy_at(array(_sz)); } T & back() { return *array(_sz-1); } @@ -132,7 +132,7 @@ public: size_t byteCapacity() const { return _array.size(); } size_t capacity() const { return _array.size()/sizeof(T); } void clear() { - std::_Destroy(array(0), array(_sz)); + std::destroy(array(0), array(_sz)); _sz = 0; } bool empty() const { return _sz == 0; } diff --git a/vespalib/src/vespa/vespalib/util/array.hpp b/vespalib/src/vespa/vespalib/util/array.hpp index 771251f1675..6ef2ad6b687 100644 --- a/vespalib/src/vespa/vespalib/util/array.hpp +++ b/vespalib/src/vespa/vespalib/util/array.hpp @@ -12,7 +12,7 @@ template void construct(T * dest, const T * source, size_t sz, std::tr1::false_type) { for (size_t i(0); i < sz; i++) { - std::_Construct(dest + i, *(source + i)); + ::new (static_cast(dest + i)) T(*(source + i)); } } @@ -115,7 +115,7 @@ void Array::resize(size_t n) if (n > _sz) { construct(array(_sz), n-_sz, std::tr1::has_trivial_destructor()); } else if (n < _sz) { - std::_Destroy(array(n), array(_sz)); + std::destroy(array(n), array(_sz)); } _sz = n; } @@ -124,8 +124,8 @@ template void move(T * dest, T * source, size_t sz, std::tr1::false_type) { for (size_t i(0); i < sz; i++) { - std::_Construct(dest + i, std::move(*(source + i))); - std::_Destroy(source + i); + ::new (static_cast(dest + i)) T(std::move(*(source + i))); + std::destroy_at(source + i); } } @@ -200,7 +200,7 @@ Array::~Array() template void Array::cleanup() { - std::_Destroy(array(0), array(_sz)); + std::destroy(array(0), array(_sz)); _sz = 0; Alloc().swap(_array); } -- cgit v1.2.3