@@ -32,8 +32,8 @@ namespace details {
32
32
* @brief This class represents a Smart Pointer that works as a \c weak_ptr but has the API of a \c shared_ptr .
33
33
*
34
34
* A \c fragile_ptr is a Smart Pointer that holds a weak reference to an object of kind \c T .
35
- * A weak reference implies that there is no assurance that this object will exit (will not be destroyed somewhere
36
- * else) all along the life of this object.
35
+ * A weak reference implies that there is no assurance that this object will exist (will not be destroyed somewhere
36
+ * else) along the lifetime of this object.
37
37
* This class replicates the API of a shared_ptr and those times that the internal reference is used
38
38
* (operator-> and operator*) it throws an exception if the internal reference has expired.
39
39
*
@@ -61,13 +61,13 @@ class fragile_ptr
61
61
fragile_ptr () noexcept = default ;
62
62
63
63
// ! Default constructors and operator= from other \c fragile_ptr ( \c weak_ptr are copiable and moveable).
64
- fragile_ptr (const fragile_ptr<T>& copy_other) = default ;
65
- fragile_ptr (fragile_ptr<T>&& move_other) = default ;
66
- fragile_ptr& operator =(const fragile_ptr<T>& copy_other) = default ;
67
- fragile_ptr& operator =(fragile_ptr<T>&& move_other) = default ;
64
+ fragile_ptr (const fragile_ptr<T>& copy_other) noexcept = default ;
65
+ fragile_ptr (fragile_ptr<T>&& move_other) noexcept = default ;
66
+ fragile_ptr& operator =(const fragile_ptr<T>& copy_other) noexcept = default ;
67
+ fragile_ptr& operator =(fragile_ptr<T>&& move_other) noexcept = default ;
68
68
69
69
// ! Default destructor
70
- virtual ~fragile_ptr () = default ;
70
+ ~fragile_ptr () = default ;
71
71
72
72
// ///////////////////
73
73
// CONSTRUCTORS FROM SHARED PTR
@@ -79,28 +79,28 @@ class fragile_ptr
79
79
*
80
80
* @param shared_reference \c shared_ptr to the reference to point from this.
81
81
*/
82
- fragile_ptr (const std::shared_ptr<T>& shared_reference)
82
+ fragile_ptr (const std::shared_ptr<T>& shared_reference) noexcept
83
83
: reference_(shared_reference)
84
84
{
85
85
// Do nothing
86
86
}
87
87
88
88
// ! Same as calling basic constructor.
89
- fragile_ptr (std::nullptr_t )
89
+ fragile_ptr (std::nullptr_t ) noexcept
90
90
{
91
91
// Do nothing
92
92
}
93
93
94
94
/* *
95
- * @brief Construct a new fragile ptr object from a shared one
95
+ * @brief Assign the fragile ptr object from a shared one
96
96
*
97
97
* It initializes the internal \c weak_ptr with the reference of the shared one.
98
98
*
99
99
* @param shared_reference \c shared_ptr to the reference to point from this.
100
100
*/
101
- fragile_ptr& operator =(const std::shared_ptr<T>& copy_other)
101
+ fragile_ptr& operator =(const std::shared_ptr<T>& shared_reference) noexcept
102
102
{
103
- this ->reference_ = copy_other ;
103
+ this ->reference_ = shared_reference ;
104
104
return *this ;
105
105
}
106
106
@@ -110,7 +110,9 @@ class fragile_ptr
110
110
/* *
111
111
* @brief Compare this ptr reference with a shared one.
112
112
*
113
- * @todo use if_enabled or somehow limit this cast to only those U that are coherent
113
+ * @param other \c shared_ptr to compare with.
114
+ *
115
+ * @todo use if_enabled or somehow limit this cast to only those U that are coherent.
114
116
*/
115
117
template <typename U>
116
118
bool operator ==(const std::shared_ptr<U>& other) const noexcept
@@ -125,7 +127,7 @@ class fragile_ptr
125
127
/* *
126
128
* @brief Cast this object to a \c shared_ptr object of type \c U .
127
129
*
128
- * @todo use if_enabled or somehow limit this cast to only those U that are coherent
130
+ * @todo use if_enabled or somehow limit this cast to only those U that are coherent.
129
131
*/
130
132
template <typename U>
131
133
operator std::shared_ptr<U> () const
@@ -143,12 +145,12 @@ class fragile_ptr
143
145
}
144
146
145
147
// ! Cast this object to a \c shared_ptr of the same type.
146
- operator std::shared_ptr<T>() const
148
+ operator std::shared_ptr<T>() const noexcept
147
149
{
148
150
return this ->lock ();
149
151
}
150
152
151
- // ! Wether the internal ptr is valid (it it has been initialized and it has expired).
153
+ // ! Whether the internal ptr is valid (it has been initialized and has not expired).
152
154
operator bool () const noexcept
153
155
{
154
156
return !reference_.expired ();
@@ -186,7 +188,7 @@ class fragile_ptr
186
188
*
187
189
* @return T* internal reference (could be null)
188
190
*/
189
- T* get () const
191
+ T* get () const noexcept
190
192
{
191
193
return lock ().get ();
192
194
}
@@ -225,7 +227,8 @@ class fragile_ptr
225
227
* @brief This method calls \c weak_ptr::lock . In case the reference is not valid anymore
226
228
* it throws an exception to warn about its usage.
227
229
*
228
- * It uses for those cases where using the internal reference must be protected by an exception call in error case.
230
+ * It is used for those cases where using the internal reference must be protected by an exception call
231
+ * in case of error.
229
232
*
230
233
* @return return of shared_ptr result from lock
231
234
* @throw \c Inconsistency if the internal reference is not valid.
0 commit comments