summaryrefslogtreecommitdiff
path: root/include/mbgl/style/conversion_impl.hpp
diff options
context:
space:
mode:
authorAlexander Shalamov <alexander.shalamov@mapbox.com>2019-04-05 17:22:55 +0300
committerAlexander Shalamov <alexander.shalamov@mapbox.com>2019-04-05 19:46:50 +0300
commit1721ce26f0d20f3a96254dc655adaf3260040a14 (patch)
tree69977c5b7b0a764d7b98709baa50d3df61bb8c50 /include/mbgl/style/conversion_impl.hpp
parent5a173faec1aed27e08cdded48371cf9c7752b779 (diff)
downloadqtlocation-mapboxgl-1721ce26f0d20f3a96254dc655adaf3260040a14.tar.gz
[core] Move should not call destructorsupstream/alexshalamov_dont_delete_while_moving
Diffstat (limited to 'include/mbgl/style/conversion_impl.hpp')
-rw-r--r--include/mbgl/style/conversion_impl.hpp25
1 files changed, 6 insertions, 19 deletions
diff --git a/include/mbgl/style/conversion_impl.hpp b/include/mbgl/style/conversion_impl.hpp
index 27b2ee1917..d61dd3d10b 100644
--- a/include/mbgl/style/conversion_impl.hpp
+++ b/include/mbgl/style/conversion_impl.hpp
@@ -89,29 +89,18 @@ public:
new (static_cast<void*>(&storage)) std::decay_t<T>(std::forward<T>(value));
}
- Convertible(Convertible&& v)
- : vtable(v.vtable)
- {
- if (vtable) {
- vtable->move(std::move(v.storage), this->storage);
- }
+ Convertible(Convertible&& v) : vtable(v.vtable) {
+ vtable->move(std::move(v.storage), storage);
}
~Convertible() {
- if (vtable) {
- vtable->destroy(storage);
- }
+ vtable->destroy(storage);
}
Convertible& operator=(Convertible&& v) {
- if (vtable) {
- vtable->destroy(storage);
- }
+ vtable->destroy(storage);
vtable = v.vtable;
- if (vtable) {
- vtable->move(std::move(v.storage), this->storage);
- }
- v.vtable = nullptr;
+ vtable->move(std::move(v.storage), storage);
return *this;
}
@@ -235,9 +224,7 @@ private:
using Traits = ConversionTraits<T>;
static VTable vtable = {
[] (Storage&& src, Storage& dest) {
- auto srcValue = reinterpret_cast<T&&>(src);
- new (static_cast<void*>(&dest)) T(std::move(srcValue));
- srcValue.~T();
+ new (static_cast<void*>(&dest)) T(reinterpret_cast<T&&>(src));
},
[] (Storage& s) {
reinterpret_cast<T&>(s).~T();