set - 编译时已经知道函数类型
multiset<Sales_data, decltype(compareIsbn)*> bookstore(compareIsbn);
shared_ptr -- 运行时绑定
shared_ptr<connection> sp1(&c, [c](){disconnection(&c);});
shared_ptr<int> sp(new int[10], [](int* p){delete[] p;}); //用shared_ptr管理动态数组,需要提供一个删除器
unique_ptr - 编译时已经知道函数类型
unique_ptr<connection, decltype<end_connection>*> p(&c, end_connection);
本文探讨了C++中智能指针(shared_ptr, unique_ptr)的高级用法及自定义删除器的应用,并介绍了set和multiset容器的具体实例,展示了如何在编译时确定函数类型。
325

被折叠的 条评论
为什么被折叠?



