Skip to content

Commit

Permalink
src: remove usage of std::shared_ptr<T>::unique()
Browse files Browse the repository at this point in the history
`std::shared_ptr<T>::unique()` has been removed in C++20, so this change
uses `std::shared_ptr<T>::use_count()` instead which is available in
C++20.

Fixes: #47311
Signed-off-by: Darshan Sen <raisinten@gmail.com>
PR-URL: #47315
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
RaisinTen authored and RafaelGSS committed Apr 5, 2023
1 parent 06d92d6 commit d3d050e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/node_threadsafe_cow-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace node {

template <typename T>
T* CopyOnWrite<T>::write() {
if (!data_.unique()) {
if (data_.use_count() > 1l) {
data_ = std::make_shared<T>(*data_);
}
return data_.get();
Expand Down

0 comments on commit d3d050e

Please sign in to comment.