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 c962338..af391f8 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 7e130b4..f87888a 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 6efc679..730030c 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 15b3181..3297ced 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 118cc90..1db2e94 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 47d51fb..eb78cb6 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 cb1f8d5..a06de9a 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 02c865a..6a2b52b 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 fcf5b17..de43c91 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 1fae077..5027224 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 4c1ad7f..2ea7012 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 d9bfb70..3fa22e4 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 e0e612e..186a45b 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 e275473..9a89281 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 5dee0fe..fc264d4 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 a57baa1..8e54756 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 2e86679..9d204fc 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 05e20c8..70c74a6 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 579ec48..41ec6f0 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 181d553..99ac90e 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 586d4f9..5aab626 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
 };