noexcept move for BaseHandle/InstrusivePtr/Math 34/282634/4
authorEunki, Hong <eunkiki.hong@samsung.com>
Fri, 7 Oct 2022 04:48:47 +0000 (13:48 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Mon, 10 Oct 2022 10:30:54 +0000 (19:30 +0900)
It can be optimize when we use std::vector<> or
std::is_nothrow_move_constructible<>::value is true or
std::is_nothrow_move_assignable<>::value is true.

Change-Id: I5a8866b928d40d7e26a68486c5aef764bc68a9af
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
21 files changed:
dali/public-api/common/intrusive-ptr.h
dali/public-api/math/degree.h
dali/public-api/math/matrix.cpp
dali/public-api/math/matrix.h
dali/public-api/math/matrix3.cpp
dali/public-api/math/matrix3.h
dali/public-api/math/quaternion.h
dali/public-api/math/radian.h
dali/public-api/math/rect.h
dali/public-api/math/vector2.h
dali/public-api/math/vector3.h
dali/public-api/math/vector4.h
dali/public-api/object/base-handle.cpp
dali/public-api/object/base-handle.h
dali/public-api/object/indirect-value.cpp
dali/public-api/object/indirect-value.h
dali/public-api/object/property-array.cpp
dali/public-api/object/property-array.h
dali/public-api/object/property-map.cpp
dali/public-api/object/property-map.h
dali/public-api/object/ref-object.h

index c962338030b1b58a81ee27e72a179b47b9ac90d9..af391f8bf062d039b7075c6cc1bc1d86944bcbc7 100644 (file)
@@ -103,7 +103,7 @@ public:
    * @param[in] rhs Reference to an IntrusivePtr
    */
   template<typename U>
-  IntrusivePtr(IntrusivePtr<U>&& rhs)
+  IntrusivePtr(IntrusivePtr<U>&& rhs) noexcept
   : mPtr(rhs.Detach())
   {
   }
@@ -113,7 +113,7 @@ public:
    * @SINCE_1_9.23
    * @param[in] rhs Reference to an IntrusivePtr
    */
-  IntrusivePtr(IntrusivePtr&& rhs)
+  IntrusivePtr(IntrusivePtr&& rhs) noexcept
   : mPtr(rhs.Detach())
   {
   }
@@ -198,7 +198,7 @@ public:
    * @param rhs Reference to intrusive pointer
    * @return Reference to moved intrusive pointer
    */
-  IntrusivePtr& operator=(IntrusivePtr&& rhs)
+  IntrusivePtr& operator=(IntrusivePtr&& rhs) noexcept
   {
     if(this != &rhs)
     {
@@ -220,7 +220,7 @@ public:
    * @return Reference to moved intrusive pointer
    */
   template<typename U>
-  IntrusivePtr& operator=(IntrusivePtr<U>&& rhs)
+  IntrusivePtr& operator=(IntrusivePtr<U>&& rhs) noexcept
   {
     if(this != reinterpret_cast<IntrusivePtr<T>*>(&rhs))
     {
index 7e130b4138c739a337946883523d6aeeb83b91d4..f87888af8bbfb241b6f512dc26a35fd77f72bc83 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_DEGREE_H
 
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -69,10 +69,10 @@ struct Degree
   DALI_CORE_API Degree(Radian value);
 
 public:
-  Degree(const Degree&) = default;            ///< Default copy constructor
-  Degree(Degree&&)      = default;            ///< Default move constructor
-  Degree& operator=(const Degree&) = default; ///< Default copy assignment operator
-  Degree& operator=(Degree&&) = default;      ///< Default move assignment operator
+  Degree(const Degree&)     = default;            ///< Default copy constructor
+  Degree(Degree&&) noexcept = default;            ///< Default move constructor
+  Degree& operator=(const Degree&) = default;     ///< Default copy assignment operator
+  Degree& operator=(Degree&&) noexcept = default; ///< Default move assignment operator
 
 public:
   // member data
index 6efc679ad5b02abc54dda32038ad53185b3bb14f..730030cb790ff1c885303edf541b07a917a3fa60 100644 (file)
@@ -137,12 +137,12 @@ Matrix& Matrix::operator=(const Matrix& matrix)
   return *this;
 }
 
-Matrix::Matrix(Matrix&& matrix)
+Matrix::Matrix(Matrix&& matrix) noexcept
 {
   memcpy(mMatrix, matrix.mMatrix, NUM_BYTES_IN_MATRIX);
 }
 
-Matrix& Matrix::operator=(Matrix&& matrix)
+Matrix& Matrix::operator=(Matrix&& matrix) noexcept
 {
   if(this != &matrix)
   {
index 15b3181c353a98d7d955cbdba908f2e54ef58384..3297ced5910d4a884ec8a863f5c9d3f8686eacbb 100644 (file)
@@ -123,7 +123,7 @@ public:
    * @SINCE_1_9.21
    * @param[in] matrix A reference to the moved matrix
    */
-  Matrix(Matrix&& matrix);
+  Matrix(Matrix&& matrix) noexcept;
 
   /**
    * @brief Move assignment operator.
@@ -132,7 +132,7 @@ public:
    * @param[in] matrix A reference to the moved matrix
    * @return A reference to this
    */
-  Matrix& operator=(Matrix&& matrix);
+  Matrix& operator=(Matrix&& matrix) noexcept;
 
   /**
    * @brief The identity matrix.
index 118cc90df7121c2441e77f23d56c2b719b98f317..1db2e9425273bdfdab7dd1c11cffce628316bfb8 100644 (file)
@@ -92,12 +92,12 @@ void Matrix3::SetIdentity()
   mElements[S22] = 1.0f;
 }
 
-Matrix3::Matrix3(Matrix3&& matrix)
+Matrix3::Matrix3(Matrix3&& matrix) noexcept
 {
   memcpy(mElements, matrix.mElements, NUM_BYTES_IN_MATRIX);
 }
 
-Matrix3& Matrix3::operator=(Matrix3&& matrix)
+Matrix3& Matrix3::operator=(Matrix3&& matrix) noexcept
 {
   if(this != &matrix)
   {
index 47d51fbd2fbf634b19f626da2801b1ff2898145e..eb78cb6a1ac6308b7318d0c920dc8de58ad58a40 100644 (file)
@@ -106,7 +106,7 @@ public:
    * @SINCE_1_9.21
    * @param[in] matrix A reference to the moved matrix
    */
-  Matrix3(Matrix3&& matrix);
+  Matrix3(Matrix3&& matrix) noexcept;
 
   /**
    * @brief Move assignment operator.
@@ -115,7 +115,7 @@ public:
    * @param[in] matrix A reference to the moved matrix
    * @return A reference to this
    */
-  Matrix3& operator=(Matrix3&& matrix);
+  Matrix3& operator=(Matrix3&& matrix) noexcept;
 
   /**
    * @brief Assignment Operator.
index cb1f8d5ecba7798a2991d9fa51f016c60d752b16..a06de9a630e400d48886bf03d26f60aabef3b27f 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_QUATERNION_H
 
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -466,10 +466,10 @@ private:
   /// @endcond
 
 public:
-  Quaternion(const Quaternion&) = default;            ///< Default copy constructor
-  Quaternion(Quaternion&&)      = default;            ///< Default move constructor
-  Quaternion& operator=(const Quaternion&) = default; ///< Default copy assignment operator
-  Quaternion& operator=(Quaternion&&) = default;      ///< Default move assignment operator
+  Quaternion(const Quaternion&)     = default;            ///< Default copy constructor
+  Quaternion(Quaternion&&) noexcept = default;            ///< Default move constructor
+  Quaternion& operator=(const Quaternion&) = default;     ///< Default copy assignment operator
+  Quaternion& operator=(Quaternion&&) noexcept = default; ///< Default move assignment operator
 
 public:
   Vector4 mVector; ///< w component is s ( = cos(theta/2.0) )
index 02c865a04e791766d5f052c0ef5a7e67a4784afc..6a2b52b27815e0272e407afcdf7a403d9d3bdbca 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_RADIAN_H
 
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -107,10 +107,10 @@ struct Radian
   }
 
 public:
-  Radian(const Radian&) = default;            ///< Default copy constructor
-  Radian(Radian&&)      = default;            ///< Default move constructor
-  Radian& operator=(const Radian&) = default; ///< Default copy assignment operator
-  Radian& operator=(Radian&&) = default;      ///< Default move assignment operator
+  Radian(const Radian&)     = default;            ///< Default copy constructor
+  Radian(Radian&&) noexcept = default;            ///< Default move constructor
+  Radian& operator=(const Radian&) = default;     ///< Default copy assignment operator
+  Radian& operator=(Radian&&) noexcept = default; ///< Default move assignment operator
 
 public:
   // member data
index fcf5b1710b090180b4fef28c87bc2dbf686f6136..de43c9125b0d042c77a7ea2ae4eeacbad12fe185 100644 (file)
@@ -107,7 +107,7 @@ struct Rect
    * @SINCE_1_9.27
    * @param[in] rhs The original object
    */
-  Rect<T>(Rect<T>&& rhs) = default;
+  Rect<T>(Rect<T>&& rhs) noexcept = default;
 
   /**
    * @brief Default move assignment operator.
@@ -116,7 +116,7 @@ struct Rect
    * @param[in] rhs The original object
    * @return Reference to this
    */
-  Rect<T>& operator=(Rect<T>&& rhs) = default;
+  Rect<T>& operator=(Rect<T>&& rhs) noexcept = default;
 
   /**
    * @brief Assignment operator.
index 1fae07763ddbdb7d97fe344cbe5ae546b8c127d2..50272243e03f09ba3d1af6c7045ddc998a7c0338 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_VECTOR_2_H
 
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -452,10 +452,10 @@ public:
   }
 
 public:
-  Vector2(const Vector2&) = default;            ///< Default copy constructor
-  Vector2(Vector2&&)      = default;            ///< Default move constructor
-  Vector2& operator=(const Vector2&) = default; ///< Default copy assignment operator
-  Vector2& operator=(Vector2&&) = default;      ///< Default move assignment operator
+  Vector2(const Vector2&)     = default;            ///< Default copy constructor
+  Vector2(Vector2&&) noexcept = default;            ///< Default move constructor
+  Vector2& operator=(const Vector2&) = default;     ///< Default copy assignment operator
+  Vector2& operator=(Vector2&&) noexcept = default; ///< Default move assignment operator
 
 public: // Data
   // NOTE
index 4c1ad7f072c2ce538304f8d644515326f33d818c..2ea7012a58d8d00beea210c1393c8b4abaa2422a 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_VECTOR_3_H
 
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -569,10 +569,10 @@ struct DALI_CORE_API Vector3
   };
 
 public:
-  Vector3(const Vector3&) = default;            ///< Default copy constructor
-  Vector3(Vector3&&)      = default;            ///< Default move constructor
-  Vector3& operator=(const Vector3&) = default; ///< Default copy assignment operator
-  Vector3& operator=(Vector3&&) = default;      ///< Default move assignment operator
+  Vector3(const Vector3&)     = default;            ///< Default copy constructor
+  Vector3(Vector3&&) noexcept = default;            ///< Default move constructor
+  Vector3& operator=(const Vector3&) = default;     ///< Default copy assignment operator
+  Vector3& operator=(Vector3&&) noexcept = default; ///< Default move assignment operator
 };
 
 /**
index d9bfb706eb06c9c6689558b85234199a02765118..3fa22e4802d98f8edc453a32f49f7c4c1ccdaf59 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_VECTOR_4_H
 
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -567,10 +567,10 @@ struct DALI_CORE_API Vector4
   };
 
 public:
-  Vector4(const Vector4&) = default;            ///< Default copy constructor
-  Vector4(Vector4&&)      = default;            ///< Default move constructor
-  Vector4& operator=(const Vector4&) = default; ///< Default copy assignment operator
-  Vector4& operator=(Vector4&&) = default;      ///< Default move assignment operator
+  Vector4(const Vector4&)     = default;            ///< Default copy constructor
+  Vector4(Vector4&&) noexcept = default;            ///< Default move constructor
+  Vector4& operator=(const Vector4&) = default;     ///< Default copy assignment operator
+  Vector4& operator=(Vector4&&) noexcept = default; ///< Default move assignment operator
 };
 
 /**
index e0e612e502156befe7050884a8f49fff4c1afefc..186a45bba91f6a626e85b7585b5d56d59cb00a5d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -41,9 +41,9 @@ BaseHandle::BaseHandle(const BaseHandle& handle) = default;
 
 BaseHandle& BaseHandle::operator=(const BaseHandle& rhs) = default;
 
-BaseHandle::BaseHandle(BaseHandle&& rhs) = default;
+BaseHandle::BaseHandle(BaseHandle&& rhs) noexcept = default;
 
-BaseHandle& BaseHandle::operator=(BaseHandle&& rhs) = default;
+BaseHandle& BaseHandle::operator=(BaseHandle&& rhs) noexcept = default;
 
 bool BaseHandle::DoAction(const std::string& command, const Property::Map& attributes)
 {
index e275473fa41cc740358284fc53731779226a029f..9a8928143a032822a278e8f243483482d2a14ecc 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_BASE_HANDLE_H
 
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -115,7 +115,7 @@ public:
    * @SINCE_1_9.22
    * @param[in] rhs A reference to the moved handle
    */
-  BaseHandle(BaseHandle&& rhs);
+  BaseHandle(BaseHandle&& rhs) noexcept;
 
   /**
    * @brief Move assignment operator.
@@ -124,7 +124,7 @@ public:
    * @param[in] rhs A reference to the moved handle
    * @return A reference to this handle
    */
-  BaseHandle& operator=(BaseHandle&& rhs);
+  BaseHandle& operator=(BaseHandle&& rhs) noexcept;
 
   /**
    * @brief Connects a void() functor to a specified signal.
index 5dee0fec6137867dcdc24bb06432a68039a92f74..fc264d467604cc69e15218f8a737c9b837112341 100644 (file)
@@ -37,8 +37,8 @@ Property::Value IndirectValue::GetProperty()
   return Handle(static_cast<Dali::Internal::Object*>(mHandle.Get())).GetProperty(mIndex);
 }
 
-IndirectValue& IndirectValue::operator=(IndirectValue&&) = default;
+IndirectValue& IndirectValue::operator=(IndirectValue&&) noexcept = default;
 
-IndirectValue::IndirectValue(IndirectValue&&) = default;
+IndirectValue::IndirectValue(IndirectValue&&) noexcept = default;
 
 } // namespace Dali
index a57baa1c4568445a92107265e802dda3b0f679d2..8e54756f4d1957f014508071a61bdbd23da061ec 100644 (file)
@@ -91,7 +91,7 @@ private:
    * Making this private to prevent construction of auto type or IndirectValue type.
    * @param[in] rhs The object to move
    */
-  DALI_INTERNAL IndirectValue(IndirectValue&& rhs);
+  DALI_INTERNAL IndirectValue(IndirectValue&& rhs) noexcept;
 
   /**
    * @brief Move assignment operator.
@@ -100,7 +100,7 @@ private:
    * Making this private to prevent assignment to auto type or IndirectValue type.
    * @param[in] rhs The object to move
    */
-  DALI_INTERNAL IndirectValue& operator=(IndirectValue&& rhs);
+  DALI_INTERNAL IndirectValue& operator=(IndirectValue&& rhs) noexcept;
 
   /**
    * @brief Accessor for handle property.
index 2e866793a4decb75b8c1a060dd2f6c3dac83a2b0..9d204fc4989ace92bc53f39234557fcb235ba14c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -54,7 +54,7 @@ Property::Array::Array(const Property::Array& other)
   mImpl->mArray = other.mImpl->mArray;
 }
 
-Property::Array::Array(Property::Array&& other)
+Property::Array::Array(Property::Array&& other) noexcept
 : mImpl(other.mImpl)
 {
   other.mImpl = nullptr;
@@ -128,7 +128,7 @@ Property::Array& Property::Array::operator=(const Property::Array& other)
   return *this;
 }
 
-Property::Array& Property::Array::operator=(Property::Array&& other)
+Property::Array& Property::Array::operator=(Property::Array&& other) noexcept
 {
   if(this != &other)
   {
index 05e20c83fd29dbe3d41dc58ab1f1b201aba1fe5f..70c74a6eaeb0828ad50c1d0aa46f8922da76c1e8 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_PROPERTY_ARRAY_H
 
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -73,7 +73,7 @@ public:
    * @param[in] other The Array to move from
    * @note After the @a other array is used, it becomes invalid and is no longer usable.
    */
-  Array(Array&& other);
+  Array(Array&& other) noexcept;
 
   /**
    * @brief Non-virtual destructor.
@@ -224,7 +224,7 @@ public:
    *
    * @note After the @a other array is used, it becomes invalid and is no longer usable.
    */
-  Array& operator=(Array&& other);
+  Array& operator=(Array&& other) noexcept;
 
   /**
    * @brief Output to stream.
index 579ec483c78f102f05e516ff6ac5e746d17b3d5f..41ec6f0c45e26cdc56375fcfada0deaab6bbd7fb 100644 (file)
@@ -75,7 +75,7 @@ Property::Map::Map(const Property::Map& other)
   mImpl->mIndexValueContainer  = other.mImpl->mIndexValueContainer;
 }
 
-Property::Map::Map(Property::Map&& other)
+Property::Map::Map(Property::Map&& other) noexcept
 : mImpl(other.mImpl)
 {
   other.mImpl = nullptr;
@@ -395,7 +395,7 @@ Property::Map& Property::Map::operator=(const Property::Map& other)
   return *this;
 }
 
-Property::Map& Property::Map::operator=(Property::Map&& other)
+Property::Map& Property::Map::operator=(Property::Map&& other) noexcept
 {
   if(this != &other)
   {
index 181d5530915e97f4c807afa0f3d796204e05f71a..99ac90e933eb846d5d18285f0b7a45a4ea8ab4fe 100755 (executable)
@@ -78,7 +78,7 @@ public:
    * @param[in] other The Map to move from
    * @note After the @a other array is used, it becomes invalid and is no longer usable.
    */
-  Map(Map&& other);
+  Map(Map&& other) noexcept;
 
   /**
    * @brief Non-virtual destructor.
@@ -368,7 +368,7 @@ public:
    *
    * @note The other array is an r-value so becomes invalid and is no longer usable.
    */
-  Map& operator=(Map&& other);
+  Map& operator=(Map&& other) noexcept;
 
   /**
    * @brief Output to stream.
index 586d4f953bada548aefc8806db06f23aacf6f97f..5aab626c43ed03f8008d16634ae91822e308b90e 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_REF_OBJECT_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -101,6 +101,11 @@ protected:
    */
   RefObject& operator=(const RefObject& rhs);
 
+  // Not movable
+
+  RefObject(RefObject&& rhs) = delete;            ///< Deleted move constructor
+  RefObject& operator=(RefObject&& rhs) = delete; ///< Deleted move assignment operator
+
 private:
   std::atomic_uint32_t mCount{0u}; ///< Reference count
 };