Why is std::shared_ptr::unique() deprecated?
What is the technical problem with std::shared_ptr::unique() that is the reason for its deprecation in C++17? According to cppreference.com , std::shared_ptr::unique() is deprecated in C++17 as this function is deprecated as of C++17 because use_count is only an approximation in multi-threaded environment. I understand this to be true for use_count() > 1 : While I'm holding a reference to it, someone else might simultaneously let go of his or create a new copy. But if use_count() returns 1 (which is what I'm interested in when calling unique() ) then there is no other thread that could change