Skip to content

Commit 9580b19

Browse files
committed
Added missing operator bool() to observer_ptr
1 parent 7a2d89c commit 9580b19

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

include/oup/observable_unique_ptr.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,13 @@ class observer_ptr : private std::weak_ptr<T> {
382382
return std::weak_ptr<T>::lock().get();
383383
}
384384

385+
/// Check if this pointer points to a valid object.
386+
/** \return 'true' if the pointed object is valid, 'false' otherwise
387+
*/
388+
explicit operator bool() noexcept {
389+
return !expired();
390+
}
391+
385392
/// Swap the content of this pointer with that of another pointer.
386393
/** \param other The other pointer to swap with
387394
*/

0 commit comments

Comments
 (0)