After explicit operation bool() patch, Dali::InstrusivePtr == nullptr make compile error.
This patch fix that situation, so keep codes legacy
Change-Id: I6fbdee55203a1a0e9b5d3a90125497957dddeced
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
/*
- * 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.
END_TEST;
}
+int UtcDaliBaseHandleInequalityWithNullptr(void)
+{
+ TestApplication application;
+ tet_infoline("Test for Dali::BaseHandle::operator == nullptr");
+
+ BaseHandle object;
+
+ // object is nullptr.
+ DALI_TEST_CHECK(object == nullptr);
+ DALI_TEST_CHECK(nullptr == object);
+ DALI_TEST_CHECK(!(object != nullptr));
+ DALI_TEST_CHECK(!(nullptr != object));
+
+ object = Actor::New();
+
+ // object is not nullptr.
+ DALI_TEST_CHECK(!(object == nullptr));
+ DALI_TEST_CHECK(!(nullptr == object));
+ DALI_TEST_CHECK(object != nullptr);
+ DALI_TEST_CHECK(nullptr != object);
+
+ END_TEST;
+}
+
int UtcDaliBaseHandleStlVector(void)
{
TestApplication application;
/*
- * 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.
END_TEST;
}
+
+/** Equality with nullptr */
+int UtcDaliIntrusivePtrOperatorEqualWithNullptr(void)
+{
+ tet_infoline("Test for Dali::IntrusivePtr::operator == nullptr");
+
+ IntrusivePtr<Counted> counted1(new Counted);
+
+ // counted1 is not nullptr.
+ DALI_TEST_CHECK(!(counted1 == nullptr));
+ DALI_TEST_CHECK(!(nullptr == counted1));
+ DALI_TEST_CHECK(counted1 != nullptr);
+ DALI_TEST_CHECK(nullptr != counted1);
+
+ counted1 = nullptr;
+
+ // counted1 is nullptr.
+ DALI_TEST_CHECK(counted1 == nullptr);
+ DALI_TEST_CHECK(nullptr == counted1);
+ DALI_TEST_CHECK(!(counted1 != nullptr));
+ DALI_TEST_CHECK(!(nullptr != counted1));
+
+ END_TEST;
+}
#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>
}
/**
+ * @brief Comparison overrides of objects with nullptr_t.
+ *
+ * @SINCE_2_1.11
+ * @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.11
+ * @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.11
+ * @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.11
+ * @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