From afc986f741ffa937f318c2ed536f979ffa8651c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steven=20Dee=20=28J=C5=8Dshin=29?= Date: Tue, 25 Mar 2025 01:49:34 -0400 Subject: [PATCH] Fix shared_ptr::owner_before (#1390) `!(a < b)` is not the same as `b < a`. I think I originally wrote it this way to avoid making weak_ptr a friend of shared_ptr, but weak_ptr already is a friend. --- ctl/shared_ptr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ctl/shared_ptr.h b/ctl/shared_ptr.h index df3865377..c387f2198 100644 --- a/ctl/shared_ptr.h +++ b/ctl/shared_ptr.h @@ -349,7 +349,7 @@ class shared_ptr template bool owner_before(const weak_ptr& r) const noexcept { - return !r.owner_before(*this); + return rc < r.rc; } private: