Skip to content

Commit 0d063af

Browse files
committed
Improved documentation
1 parent 9580b19 commit 0d063af

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

include/oup/observable_unique_ptr.hpp

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,31 @@ class observable_unique_ptr : private std::shared_ptr<T> {
6666
friend class observer_ptr;
6767

6868
public:
69-
// Import members from std::shared_ptr
69+
/// Type of the pointed object
7070
using typename std::shared_ptr<T>::element_type;
71-
using weak_type = observer_ptr<T>;
7271

72+
/// Type of the matching observer pointer
73+
using observer_type = observer_ptr<T>;
74+
75+
/// Get a non-owning raw pointer to the pointed object, or nullptr if none.
76+
/** \return 'nullptr' if no object is owned, or the pointed object otherwise
77+
*/
7378
using std::shared_ptr<T>::get;
79+
80+
/// Get a reference to the pointed object (undefined behavior if nullptr).
81+
/** \return A reference to the pointed object
82+
* \note Using this function if this pointer is null will leave to undefined behavior.
83+
*/
7484
using std::shared_ptr<T>::operator*;
85+
86+
/// Get a non-owning raw pointer to the pointed object, or nullptr if none.
87+
/** \return 'nullptr' if no object is owned, or the pointed object otherwise
88+
*/
7589
using std::shared_ptr<T>::operator->;
90+
91+
/// Check if this pointer points to a valid object.
92+
/** \return 'true' if the pointed object is valid, 'false' otherwise
93+
*/
7694
using std::shared_ptr<T>::operator bool;
7795

7896
// Define member types for compatibility with std::unique_ptr
@@ -294,10 +312,15 @@ class observer_ptr : private std::weak_ptr<T> {
294312
friend class observer_ptr;
295313

296314
public:
297-
// Import members from std::shared_ptr
315+
/// Type of the pointed object
298316
using typename std::weak_ptr<T>::element_type;
299317

318+
/// Set this pointer to null.
300319
using std::weak_ptr<T>::reset;
320+
321+
/// Check if this pointer points to a valid object.
322+
/** \return 'true' if the pointed object is valid, 'false' otherwise
323+
*/
301324
using std::weak_ptr<T>::expired;
302325

303326
/// Default constructor (null pointer).

0 commit comments

Comments
 (0)