From d9f380857e9adb659c342aff928bef9096fe3233 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 19 Nov 2021 00:35:29 -0600 Subject: [PATCH 1/2] fix: fix building on C++20 - fix removal of shared_ptr.unique This replaces the removed shared_ptr.unique with .use_count() == 1 See this for the explanation https:// en.cppreference.com/w/cpp/memory/shared_ptr/unique --- opennurbs_mesh.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/opennurbs_mesh.cpp b/opennurbs_mesh.cpp index c7c78cb2..ca06b819 100644 --- a/opennurbs_mesh.cpp +++ b/opennurbs_mesh.cpp @@ -14831,7 +14831,9 @@ bool ON_MeshCache::Transform( ON_Mesh* mesh = item->m_mesh_sp.get(); if (nullptr == mesh || mesh->IsEmpty()) continue; - if (false == item->m_mesh_sp.unique()) + // NOTE: use_count() == 1 is an approximation in multi-threaded environments + // https:// en.cppreference.com/w/cpp/memory/shared_ptr/unique + if (false == item->m_mesh_sp.use_count() == 1) { // make a copy and transform the copy std::shared_ptr(new ON_Mesh(*mesh)).swap(item->m_mesh_sp); From 71e81b4db2c2f2f5ead2fc549f894328d07012c4 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Wed, 29 Dec 2021 16:19:54 -0600 Subject: [PATCH 2/2] fix: simplify use_count comparison --- opennurbs_mesh.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opennurbs_mesh.cpp b/opennurbs_mesh.cpp index ca06b819..44428ae8 100644 --- a/opennurbs_mesh.cpp +++ b/opennurbs_mesh.cpp @@ -14833,7 +14833,7 @@ bool ON_MeshCache::Transform( continue; // NOTE: use_count() == 1 is an approximation in multi-threaded environments // https:// en.cppreference.com/w/cpp/memory/shared_ptr/unique - if (false == item->m_mesh_sp.use_count() == 1) + if (item->m_mesh_sp.use_count() != 1) { // make a copy and transform the copy std::shared_ptr(new ON_Mesh(*mesh)).swap(item->m_mesh_sp);