Effective STL 7 Delete the pointers before the container is destroyed
来源:互联网 发布:两个表格不同数据筛选 编辑:程序博客网 时间:2024/06/06 20:06
template<typename T>struct DeletObject: public unary_function<const T*, void> { void operator()(const T* ptr) const { delete ptr; }};class SpecialString:public string{...};deque<SpecialString*> dssp;...// undefined behavior! Deletion of a derived object via a base class // pointer where there is no virtual distructorfor_each(dssp.begin(), dssp.end(), DeletObject<String>());
struct DeleteObject { template<typename T> void operator()(const T* ptr) const { delete ptr; }};deque<SpecialString*> dssp;for_each(dssp.begin(), dssp.end(), DeletObject());
compilers know the type of pointer being passed to DeleteObject::operator(). so we have them automatically instantiate an operator() taking that type of pointer.
阅读全文
0 0
- Effective STL 7 Delete the pointers before the container is destroyed
- javascript错误解决:Unable to modify the parent container element before the child element is closed
- HTML Parsing Error: Unable to modify the parent container element before the child element is closed
- IE8报错:Unable to modify the parent container element before the child element is closed
- HTML Parsing Error:Unable to modify the parent container element before the child element is closed
- HTML Parsing Error: Unable to modify the parent container element before the child element is closed
- The Star Zoo——9、An animal is destroyed
- IE 8 HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)
- IE 8 HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)
- IE 8 HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)
- HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)
- IE 8 HTML Parsing Error:Unable to modify the parent container element before the child element is cl
- IE 8 HTML Parsing Error:Unable to modify the parent container element before the child element is cl
- IE 8 HTML Parsing Error: Unable to modify the parent container element before the child element is c
- IE8 中"HTML Parsing Error:Unable to modify the parent container element before the child element is c
- IE8 中"HTML Parsing Error:Unable to modify the parent container element before the child element is c
- IE8 中"HTML Parsing Error:Unable to modify the parent container element before the child element is c
- IE8 中"HTML Parsing Error:Unable to modify the parent container element before the child element is c
- 《深入理解java虚拟机》学习笔记03
- 通过设置hosts替代VPN
- centos7 安装 Nginx+Tomcat 负载均衡集群
- golang修改struct数组问题
- C#使用代码附加、分离数据库
- Effective STL 7 Delete the pointers before the container is destroyed
- Spring Boot实现自动配置的基础
- SuperIO框架
- 博客开通
- JAVA基础--自定义异常exception
- Android攻防一
- mqtt C客户端
- localStorage使用总结
- Django基础,Day3