diff --git a/include/mutex/shared_mutex.h b/include/mutex/shared_mutex.h index e96129b..816b33a 100644 --- a/include/mutex/shared_mutex.h +++ b/include/mutex/shared_mutex.h @@ -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 diff --git a/main.cpp b/main.cpp index d5f829b..a8b461b 100644 --- a/main.cpp +++ b/main.cpp @@ -71,6 +71,11 @@ TEST(资源管理, 1) { } } +TEST(资源管理, 2) { + auto mutex = ling::shared_mutex, std::shared_ptr >(std::make_shared()); + auto lock = mutex.lock_shared(); +} + TEST(排序, 堆排序测试) { std::random_device rd;