From d3d050e20f7ecfbb1c03bb2e4a0597b8470ce410 Mon Sep 17 00:00:00 2001 From: Darshan Sen Date: Thu, 30 Mar 2023 15:44:14 +0530 Subject: [PATCH] src: remove usage of `std::shared_ptr::unique()` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `std::shared_ptr::unique()` has been removed in C++20, so this change uses `std::shared_ptr::use_count()` instead which is available in C++20. Fixes: https://github.com/nodejs/node/issues/47311 Signed-off-by: Darshan Sen PR-URL: https://github.com/nodejs/node/pull/47315 Reviewed-By: Tobias Nießen Reviewed-By: Jiawen Geng Reviewed-By: Yagiz Nizipli Reviewed-By: Colin Ihrig Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell --- src/node_threadsafe_cow-inl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_threadsafe_cow-inl.h b/src/node_threadsafe_cow-inl.h index 875b38766063f6..1cd0055ed8079f 100644 --- a/src/node_threadsafe_cow-inl.h +++ b/src/node_threadsafe_cow-inl.h @@ -7,7 +7,7 @@ namespace node { template T* CopyOnWrite::write() { - if (!data_.unique()) { + if (data_.use_count() > 1l) { data_ = std::make_shared(*data_); } return data_.get();