#define DALI_INTRUSIVE_PTR_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.
*
*/
+// EXTERNAL INCLUDES
+#include <cstddef> // for std::nullptr_t
+
// INTERNAL INCLUDES
#include <dali/public-api/common/dali-common.h>
* @param[in] rhs Reference to an IntrusivePtr
*/
template<typename U>
- IntrusivePtr(IntrusivePtr<U>&& rhs)
+ IntrusivePtr(IntrusivePtr<U>&& rhs) noexcept
: mPtr(rhs.Detach())
{
}
* @SINCE_1_9.23
* @param[in] rhs Reference to an IntrusivePtr
*/
- IntrusivePtr(IntrusivePtr&& rhs)
+ IntrusivePtr(IntrusivePtr&& rhs) noexcept
: mPtr(rhs.Detach())
{
}
* @param rhs Reference to intrusive pointer
* @return Reference to moved intrusive pointer
*/
- IntrusivePtr& operator=(IntrusivePtr&& rhs)
+ IntrusivePtr& operator=(IntrusivePtr&& rhs) noexcept
{
if(this != &rhs)
{
* @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))
{
}
/**
+ * @brief Comparison overrides of objects with nullptr_t.
+ *
+ * @SINCE_2_1.12
+ * @param[in] lhs Intrusive pointer to compare with
+ * @param[in] rhs nullptr
+ * @return True if the pointers is nullptr
+ */
+template<typename T>
+inline bool operator==(IntrusivePtr<T> const& lhs, std::nullptr_t rhs)
+{
+ return lhs.Get() == nullptr;
+}
+
+/**
+ * @brief Comparison overrides of objects with nullptr_t.
+ *
+ * @SINCE_2_1.12
+ * @param[in] lhs Intrusive pointer to compare with
+ * @param[in] rhs nullptr
+ * @return True if the pointers is not nullptr
+ */
+template<typename T>
+inline bool operator!=(IntrusivePtr<T> const& lhs, std::nullptr_t rhs)
+{
+ return lhs.Get() != nullptr;
+}
+
+/**
+ * @brief Comparison overrides of objects with nullptr_t.
+ *
+ * @SINCE_2_1.12
+ * @param[in] lhs nullptr
+ * @param[in] rhs Intrusive pointer to compare against
+ * @return True if the pointers is nullptr
+ */
+template<typename T>
+inline bool operator==(std::nullptr_t lhs, IntrusivePtr<T> const& rhs)
+{
+ return nullptr == rhs.Get();
+}
+
+/**
+ * @brief Comparison overrides of objects with nullptr_t.
+ *
+ * @SINCE_2_1.12
+ * @param[in] lhs nullptr
+ * @param[in] rhs Intrusive pointer to compare against
+ * @return True if the pointers is not nullptr
+ */
+template<typename T>
+inline bool operator!=(std::nullptr_t lhs, IntrusivePtr<T> const& rhs)
+{
+ return nullptr != rhs.Get();
+}
+
+/**
* @}
*/
} // namespace Dali