【c++】模拟实现boost库下的scoped_array
来源:互联网 发布:centos 6.5搭建lnmp 编辑:程序博客网 时间:2024/06/05 11:28
//模拟实现boost库下的scoped_array#include <iostream>#include <assert.h>using namespace std;template <class T>class scoped_array{private:T * px;scoped_array(scoped_array const &);scoped_array& operator=(scoped_array const &);void operator==(scoped_array const &)const;void operator!=(scoped_array const &)const;public:scoped_array(T * p = 0) :px(p){}~scoped_array(){delete[] px;}void reset(T * p = 0){assert(p == 0 || p != px);scoped_array<T>(p).swap(*this);}T& operator[](int i)const{assert(px != 0);assert(i >= 0);return px[i];}T* get()const{return px;}void swap(scoped_array & b){T *tmp = px;px = b.px;b.px = tmp;}};int main(){int *arr = new int[100];arr[0] = 50;scoped_array<int> ptr(arr);cout << ptr[0] << endl;return 0;}
0 0
- 【c++】模拟实现boost库下的scoped_array
- boost库之scoped_array
- 【C++】智能指针的作用,模拟实现auto_ptr,scoped_ptr,shared_ptr,scoped_array,shared_array
- boost之scoped_array的使用
- boost之scoped_array的使用
- 【c++】模拟实现boost库里的scoped_ptr
- boost库学习之 scoped_ptr scoped_array
- boost库 数组智能指针scoped_array
- boost学习之-scoped_array
- boost smart_ptr 3-> scoped_array
- boost::lambda的实现模拟
- Boost源码学习---scoped_array.hpp
- boost.smart_ptr-智能指针scoped_array
- boost.smart_ptr-智能指针scoped_array
- 模拟实现boost库里的智能指针
- C++:指向数组的智能指针scoped_array组件的使用
- 模拟实现C++/boost库智能指针auto_ptr scoped_ptr和share_ptr
- 智能指针 boost(scoped_ptr,scoped_array,shared_ptr,shared_array) 和 std (auto_ptr)的比较 .
- LeetCode之Roman & Integer 的转换(简单题)
- 文章标题
- 数据报表实时分析:出身对命运的影响到底有多大?
- 实训项目银行储蓄系统
- 关于.bat文件执行一闪而过的问题
- 【c++】模拟实现boost库下的scoped_array
- otto学习
- ios 动画调试
- Javascript 面向对象编程
- day3---面向对象
- android gradle构建工具
- perl删除文件一行内容
- struts2 脱离配置文件 全注解配置
- Android中Listview(六)--索引ListView