首页 > 学院 > 开发设计 > 正文

set, shared_ptr, unique_ptr 传入可调用对象

2019-11-11 04:02:30
字体:
来源:转载
供稿:网友

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);


上一篇:XML学习

下一篇:分治法学习记录

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表