为资源代理添加==运算符

This commit is contained in:
2024-11-24 18:44:50 +08:00
parent aa2e2040dd
commit 58637627ae
2 changed files with 13 additions and 0 deletions

View File

@@ -124,6 +124,10 @@ namespace ling {
T *operator->() {
return resource;
}
bool operator==(const T *const value) {
return this->resource == value;
}
};
/// 资源的只读代理
@@ -172,6 +176,10 @@ namespace ling {
const T *operator->() const {
return resource;
}
bool operator==(const T *const value) {
return this->resource == value;
}
};
} // ling

View File

@@ -71,6 +71,11 @@ TEST(资源管理, 1) {
}
}
TEST(, 2) {
auto mutex = ling::shared_mutex<std::shared_ptr<mutex_test>, std::shared_ptr<const mutex_test> >(std::make_shared<mutex_test>());
auto lock = mutex.lock_shared();
}
TEST(, ) {
std::random_device rd;