File tree Expand file tree Collapse file tree 4 files changed +45
-0
lines changed
Expand file tree Collapse file tree 4 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -167,6 +167,15 @@ namespace YY
167167 }
168168 }
169169
170+ // / <summary>
171+ // / 检查观察者数据是否已过期。
172+ // / </summary>
173+ // / <returns>如果对象已过期,则返回 true;否则返回 false。</returns>
174+ bool __YYAPI IsExpired () const noexcept
175+ {
176+ return pObserverData == nullptr || pObserverData->IsDestroyed ();
177+ }
178+
170179 _Ret_maybenull_ __YYAPI operator _Type* () const noexcept
171180 {
172181 return Get ();
Original file line number Diff line number Diff line change @@ -101,6 +101,15 @@ namespace YY
101101
102102 return false ;
103103 }
104+
105+ // / <summary>
106+ // / 检查观察者数据是否已过期。
107+ // / </summary>
108+ // / <returns>如果对象已过期,则返回 true;否则返回 false。</returns>
109+ bool __YYAPI IsExpired () const noexcept
110+ {
111+ return uRef == 0 ;
112+ }
104113 };
105114
106115 template <typename _Type>
@@ -184,6 +193,15 @@ namespace YY
184193 Attach (_pOther);
185194 }
186195
196+ // / <summary>
197+ // / 检查观察者数据是否已过期。
198+ // / </summary>
199+ // / <returns>如果对象已过期,则返回 true;否则返回 false。</returns>
200+ bool __YYAPI IsExpired () const noexcept
201+ {
202+ return p == nullptr ;
203+ }
204+
187205 RefPtr& __YYAPI operator =(std::nullptr_t ) noexcept
188206 {
189207 Attach (nullptr );
Original file line number Diff line number Diff line change @@ -93,6 +93,15 @@ namespace YY
9393 {
9494 return &p;
9595 }
96+
97+ // / <summary>
98+ // / 检查观察者数据是否已过期。
99+ // / </summary>
100+ // / <returns>如果对象已过期,则返回 true;否则返回 false。</returns>
101+ bool __YYAPI IsExpired () const noexcept
102+ {
103+ return p == nullptr ;
104+ }
96105
97106 _Ret_maybenull_ __YYAPI operator _Type*() const noexcept
98107 {
Original file line number Diff line number Diff line change @@ -104,6 +104,15 @@ namespace YY
104104 }
105105 }
106106
107+ // / <summary>
108+ // / 检查观察者数据是否已过期。
109+ // / </summary>
110+ // / <returns>如果对象已过期,则返回 true;否则返回 false。</returns>
111+ bool __YYAPI IsExpired () const noexcept
112+ {
113+ return p == nullptr || p->IsExpired ();
114+ }
115+
107116 _Ret_maybenull_ __YYAPI operator _Type* () const noexcept
108117 {
109118 return Get ();
You can’t perform that action at this time.
0 commit comments