diff options
author | Tor Egge <Tor.Egge@broadpark.no> | 2019-06-05 19:21:06 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@broadpark.no> | 2019-06-05 19:21:06 +0200 |
commit | ea8013af74844e91db17d26dae4b24c1a5ddd76c (patch) | |
tree | d1af32ecabb0d7f75201d6c86909f909dc24fbee /vespalib | |
parent | a53e3f72b08eb8ba70f493634b0f7bc3275bd30a (diff) |
Use inplace new instead of std::_Construct
Use std::destroy or std::destroy_at instead of std::_Destroy.
Diffstat (limited to 'vespalib')
-rw-r--r-- | vespalib/src/vespa/vespalib/util/array.h | 6 | ||||
-rw-r--r-- | 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<void *>(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 <typename T> 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<void *>(dest + i)) T(*(source + i)); } } @@ -115,7 +115,7 @@ void Array<T>::resize(size_t n) if (n > _sz) { construct(array(_sz), n-_sz, std::tr1::has_trivial_destructor<T>()); } else if (n < _sz) { - std::_Destroy(array(n), array(_sz)); + std::destroy(array(n), array(_sz)); } _sz = n; } @@ -124,8 +124,8 @@ template <typename T> 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<void *>(dest + i)) T(std::move(*(source + i))); + std::destroy_at(source + i); } } @@ -200,7 +200,7 @@ Array<T>::~Array() template <typename T> void Array<T>::cleanup() { - std::_Destroy(array(0), array(_sz)); + std::destroy(array(0), array(_sz)); _sz = 0; Alloc().swap(_array); } |