diff options
author | Jacques Lucke <jacques@blender.org> | 2021-10-31 15:02:49 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-10-31 15:02:49 +0300 |
commit | 493571c3c3882df95bd86253a0c42084c413ecf7 (patch) | |
tree | c994166fa889fe82138743a5ef19a66d77a74252 | |
parent | a6eb04cce42d11ee27db58615fe063749b94423d (diff) |
add some noexcepts
-rw-r--r-- | source/blender/blenlib/BLI_any.hh | 2 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_virtual_array.hh | 14 | ||||
-rw-r--r-- | source/blender/functions/FN_generic_virtual_array.hh | 15 | ||||
-rw-r--r-- | source/blender/functions/intern/generic_virtual_array.cc | 24 |
4 files changed, 31 insertions, 24 deletions
diff --git a/source/blender/blenlib/BLI_any.hh b/source/blender/blenlib/BLI_any.hh index 8a08ec62473..34d428d10a2 100644 --- a/source/blender/blenlib/BLI_any.hh +++ b/source/blender/blenlib/BLI_any.hh @@ -181,7 +181,7 @@ class Any { * \note: The #other #Any will not be empty afterwards if it was not before. Just its value is in * a moved-from state. */ - Any(Any &&other) : info_(other.info_) + Any(Any &&other) noexcept : info_(other.info_) { info_->move_construct(&buffer_, &other.buffer_); } diff --git a/source/blender/blenlib/BLI_virtual_array.hh b/source/blender/blenlib/BLI_virtual_array.hh index fc96ccebf46..d843c7f765b 100644 --- a/source/blender/blenlib/BLI_virtual_array.hh +++ b/source/blender/blenlib/BLI_virtual_array.hh @@ -586,7 +586,7 @@ template<typename T> class VArrayCommon { } /** Move constructor. */ - VArrayCommon(VArrayCommon &&other) : storage_(std::move(other.storage_)) + VArrayCommon(VArrayCommon &&other) noexcept : storage_(std::move(other.storage_)) { impl_ = this->impl_from_storage(); other.storage_.reset(); @@ -645,7 +645,7 @@ template<typename T> class VArrayCommon { } /** Utility to implement a move assignment operator in a subclass. */ - void move_from(VArrayCommon &&other) + void move_from(VArrayCommon &&other) noexcept { if (this == &other) { return; @@ -815,7 +815,7 @@ template<typename T> class VArray : public VArrayCommon<T> { { } - VArray(VArray &&other) : VArrayCommon<T>(std::move(other)) + VArray(VArray &&other) noexcept : VArrayCommon<T>(std::move(other)) { } @@ -890,7 +890,7 @@ template<typename T> class VArray : public VArrayCommon<T> { return *this; } - VArray &operator=(VArray &&other) + VArray &operator=(VArray &&other) noexcept { this->move_from(std::move(other)); return *this; @@ -908,7 +908,7 @@ template<typename T> class VMutableArray : public VArrayCommon<T> { { } - VMutableArray(VMutableArray &&other) : VArrayCommon<T>(std::move(other)) + VMutableArray(VMutableArray &&other) noexcept : VArrayCommon<T>(std::move(other)) { } @@ -960,7 +960,7 @@ template<typename T> class VMutableArray : public VArrayCommon<T> { } /** Convert to a #VArray by moving. */ - operator VArray<T>() const && + operator VArray<T>() &&noexcept { VArray<T> varray; varray.move_from(*this); @@ -973,7 +973,7 @@ template<typename T> class VMutableArray : public VArrayCommon<T> { return *this; } - VMutableArray &operator=(VMutableArray &&other) + VMutableArray &operator=(VMutableArray &&other) noexcept { this->move_from(std::move(other)); return *this; diff --git a/source/blender/functions/FN_generic_virtual_array.hh b/source/blender/functions/FN_generic_virtual_array.hh index f31f56f92c1..cae811c4d99 100644 --- a/source/blender/functions/FN_generic_virtual_array.hh +++ b/source/blender/functions/FN_generic_virtual_array.hh @@ -120,7 +120,7 @@ class GVArrayCommon { protected: GVArrayCommon(); GVArrayCommon(const GVArrayCommon &other); - GVArrayCommon(GVArrayCommon &&other); + GVArrayCommon(GVArrayCommon &&other) noexcept; GVArrayCommon(const GVArrayImpl *impl); GVArrayCommon(std::shared_ptr<const GVArrayImpl> impl); ~GVArrayCommon(); @@ -128,7 +128,7 @@ class GVArrayCommon { template<typename ImplT, typename... Args> void emplace(Args &&...args); void copy_from(const GVArrayCommon &other); - void move_from(GVArrayCommon &&other); + void move_from(GVArrayCommon &&other) noexcept; const GVArrayImpl *impl_from_storage() const; @@ -169,7 +169,7 @@ class GVArray : public GVArrayCommon { GVArray() = default; GVArray(const GVArray &other); - GVArray(GVArray &&other); + GVArray(GVArray &&other) noexcept; GVArray(const GVArrayImpl *impl); GVArray(std::shared_ptr<const GVArrayImpl> impl); @@ -188,7 +188,7 @@ class GVArray : public GVArrayCommon { GVArray slice(IndexRange slice) const; GVArray &operator=(const GVArray &other); - GVArray &operator=(GVArray &&other); + GVArray &operator=(GVArray &&other) noexcept; const GVArrayImpl *get_implementation() const { @@ -201,7 +201,7 @@ class GVMutableArray : public GVArrayCommon { public: GVMutableArray() = default; GVMutableArray(const GVMutableArray &other); - GVMutableArray(GVMutableArray &&other); + GVMutableArray(GVMutableArray &&other) noexcept; GVMutableArray(GVMutableArrayImpl *impl); GVMutableArray(std::shared_ptr<GVMutableArrayImpl> impl); @@ -212,10 +212,11 @@ class GVMutableArray : public GVArrayCommon { static GVMutableArray ForSpan(GMutableSpan span); - operator GVArray() const; + operator GVArray() const &; + operator GVArray() &&noexcept; GVMutableArray &operator=(const GVMutableArray &other); - GVMutableArray &operator=(GVMutableArray &&other); + GVMutableArray &operator=(GVMutableArray &&other) noexcept; GMutableSpan get_internal_span() const; diff --git a/source/blender/functions/intern/generic_virtual_array.cc b/source/blender/functions/intern/generic_virtual_array.cc index 2d4bd988cde..feaf7dccd9b 100644 --- a/source/blender/functions/intern/generic_virtual_array.cc +++ b/source/blender/functions/intern/generic_virtual_array.cc @@ -459,7 +459,7 @@ GVArrayCommon::GVArrayCommon(const GVArrayCommon &other) : storage_(other.storag impl_ = this->impl_from_storage(); } -GVArrayCommon::GVArrayCommon(GVArrayCommon &&other) : storage_(std::move(other.storage_)) +GVArrayCommon::GVArrayCommon(GVArrayCommon &&other) noexcept : storage_(std::move(other.storage_)) { impl_ = this->impl_from_storage(); other.storage_.reset(); @@ -515,7 +515,7 @@ void GVArrayCommon::copy_from(const GVArrayCommon &other) impl_ = this->impl_from_storage(); } -void GVArrayCommon::move_from(GVArrayCommon &&other) +void GVArrayCommon::move_from(GVArrayCommon &&other) noexcept { if (this == &other) { return; @@ -595,7 +595,7 @@ GVArray::GVArray(const GVArray &other) : GVArrayCommon(other) { } -GVArray::GVArray(GVArray &&other) : GVArrayCommon(std::move(other)) +GVArray::GVArray(GVArray &&other) noexcept : GVArrayCommon(std::move(other)) { } @@ -659,7 +659,7 @@ GVArray &GVArray::operator=(const GVArray &other) return *this; } -GVArray &GVArray::operator=(GVArray &&other) +GVArray &GVArray::operator=(GVArray &&other) noexcept { this->move_from(std::move(other)); return *this; @@ -675,7 +675,7 @@ GVMutableArray::GVMutableArray(const GVMutableArray &other) : GVArrayCommon(othe { } -GVMutableArray::GVMutableArray(GVMutableArray &&other) : GVArrayCommon(std::move(other)) +GVMutableArray::GVMutableArray(GVMutableArray &&other) noexcept : GVArrayCommon(std::move(other)) { } @@ -693,11 +693,17 @@ GVMutableArray GVMutableArray::ForSpan(GMutableSpan span) return GVMutableArray::For<GVMutableArrayImpl_For_GMutableSpan_final>(span); } -GVMutableArray::operator GVArray() const +GVMutableArray::operator GVArray() const & { GVArray varray; - varray.impl_ = impl_; - varray.storage_ = storage_; + varray.copy_from(*this); + return varray; +} + +GVMutableArray::operator GVArray() &&noexcept +{ + GVArray varray; + varray.move_from(std::move(*this)); return varray; } @@ -707,7 +713,7 @@ GVMutableArray &GVMutableArray::operator=(const GVMutableArray &other) return *this; } -GVMutableArray &GVMutableArray::operator=(GVMutableArray &&other) +GVMutableArray &GVMutableArray::operator=(GVMutableArray &&other) noexcept { this->move_from(std::move(other)); return *this; |