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
7373 // ///////////////////
7474 // OPERATOR METHODS
7575
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+ // }
8282
8383 // TODO: use if_enabled or somehow limit this cast to only those U that are coherent
8484 template <typename U>
8585 bool operator ==(const std::shared_ptr<U>& other) const noexcept
8686 {
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+ }
8896 }
8997
9098 // ///////////////////
@@ -237,7 +245,15 @@ std::ostream& operator <<(
237245 std::ostream& o,
238246 const fragile_ptr<T>& f)
239247{
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;
241257}
242258
243259} // namespace details
You can’t perform that action at this time.
0 commit comments