We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
你好,买了你的书,不错啊! 但有个地方不太明白,你在2.1.1使用了shared_ptr::unique来断言g_foos是否为FooList的唯一引用,如果不是唯一引用,则重置。如下: void post(const Foo& f) { printf("post\n"); getlock locker(mutex); if (!g_foos.unique()) { g_foos.reset(new FooList(*g_foos)); printf("copy the whole list\n"); } assert(g_foos.unique()); g_foos->push_back(f); } 但是,我在https://zh.cppreference.com/w/cpp/memory/shared_ptr/unique这个文档中看到一段话: “此函数于 C++17 中被弃用并于 C++20 中移除,因为 use_count 在多线程环境中只是估计”。 请问如果我参考了你的解决方案,应用在项目中,后续是否有问题? 谢谢!
The text was updated successfully, but these errors were encountered:
shared_ptr::use_count了解一下
Sorry, something went wrong.
No branches or pull requests
你好,买了你的书,不错啊!
但有个地方不太明白,你在2.1.1使用了shared_ptr::unique来断言g_foos是否为FooList的唯一引用,如果不是唯一引用,则重置。如下:
void post(const Foo& f)
{
printf("post\n");
getlock locker(mutex);
if (!g_foos.unique())
{
g_foos.reset(new FooList(*g_foos));
printf("copy the whole list\n");
}
assert(g_foos.unique());
g_foos->push_back(f);
}
但是,我在https://zh.cppreference.com/w/cpp/memory/shared_ptr/unique这个文档中看到一段话:
“此函数于 C++17 中被弃用并于 C++20 中移除,因为 use_count 在多线程环境中只是估计”。
请问如果我参考了你的解决方案,应用在项目中,后续是否有问题?
谢谢!
The text was updated successfully, but these errors were encountered: