aboutsummaryrefslogtreecommitdiffhomepage
path: root/tdutils/td
diff options
context:
space:
mode:
authorlevlam <levlam@telegram.org>2025-03-01 10:44:20 +0300
committerlevlam <levlam@telegram.org>2025-03-01 10:44:20 +0300
commit7f9d6a9cdefae205c2514a6333b2ef17edda5322 (patch)
tree3494722cb0e0b3d9ca6026521b4aaeb26516589e /tdutils/td
parent8034c2cf4e733b803b062a8b330683e1b3b06137 (diff)
Add and use generic unique_ptr comparison operator.
Diffstat (limited to 'tdutils/td')
-rw-r--r--tdutils/td/utils/unique_ptr.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/tdutils/td/utils/unique_ptr.h b/tdutils/td/utils/unique_ptr.h
index b2896b10e..2cf4c98cb 100644
--- a/tdutils/td/utils/unique_ptr.h
+++ b/tdutils/td/utils/unique_ptr.h
@@ -98,6 +98,22 @@ bool operator!=(const unique_ptr<T> &p, std::nullptr_t) {
return static_cast<bool>(p);
}
+template <class T>
+bool operator==(const unique_ptr<T> &lhs, const unique_ptr<T> &rhs) {
+ if (lhs == nullptr) {
+ return rhs == nullptr;
+ }
+ if (rhs == nullptr) {
+ return false;
+ }
+ return *lhs == *rhs;
+}
+
+template <class T>
+bool operator!=(const unique_ptr<T> &lhs, const unique_ptr<T> &rhs) {
+ return !(lhs == rhs);
+}
+
template <class Type, class... Args>
unique_ptr<Type> make_unique(Args &&...args) {
return unique_ptr<Type>(new Type(std::forward<Args>(args)...));