From 58637627ae939d1a2e01c5290d569eeba660b1c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=BB=E9=AD=82=E5=9C=A3=E4=BD=BF?= Date: Sun, 24 Nov 2024 18:44:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=E8=B5=84=E6=BA=90=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=3D=3D=E8=BF=90=E7=AE=97=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/mutex/shared_mutex.h | 8 ++++++++ main.cpp | 5 +++++ 2 files changed, 13 insertions(+) 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;