File tree Expand file tree Collapse file tree 1 file changed +24
-8
lines changed Expand file tree Collapse file tree 1 file changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -73,18 +73,26 @@ class fragile_ptr
73
73
// ///////////////////
74
74
// OPERATOR METHODS
75
75
76
- template <typename U>
77
- bool operator ==(const std::shared_ptr<T>& other) const noexcept
78
- {
79
- static_assert (std::is_base_of<U, T>::value, " U must inherit from T" );
80
- return std::dynamic_pointer_cast<U>(this ->safety_lock_ ()) == other;
81
- }
76
+ // template <typename U>
77
+ // bool operator==(const std::shared_ptr<T>& other) const noexcept
78
+ // {
79
+ // static_assert(std::is_base_of<U, T>::value, "U must inherit from T");
80
+ // return std::dynamic_pointer_cast<U>(this->safety_lock_()) == other;
81
+ // }
82
82
83
83
// TODO: use if_enabled or somehow limit this cast to only those U that are coherent
84
84
template <typename U>
85
85
bool operator ==(const std::shared_ptr<U>& other) const noexcept
86
86
{
87
- return this ->safety_lock_ () == other;
87
+ static_assert (std::is_base_of<U, T>::value, " U must inherit from T" );
88
+ if (other == nullptr )
89
+ {
90
+ return this ->expired ();
91
+ }
92
+ else
93
+ {
94
+ return this ->safety_lock_ () == other;
95
+ }
88
96
}
89
97
90
98
// ///////////////////
@@ -237,7 +245,15 @@ std::ostream& operator <<(
237
245
std::ostream& o,
238
246
const fragile_ptr<T>& f)
239
247
{
240
- return o << f.lock ();
248
+ if (f.expired ())
249
+ {
250
+ o << " {nullptr}" ;
251
+ }
252
+ else
253
+ {
254
+ o << f.lock ();
255
+ }
256
+ return o;
241
257
}
242
258
243
259
} // namespace details
You can’t perform that action at this time.
0 commit comments