auto_ptr实现原型
来源:互联网 发布:企业数据备份解决方案 编辑:程序博客网 时间:2024/06/05 03:07
namespace std{
template<class Y>
struct auto_ptr_ref
{
Y* yp;
auto_ptr_ref(Y* rhs) :yp(rhs){
}
};
template<class T>
class auto_ptr{
private:
T* ap;
public:
typedef T element_type;
explicit auto_ptr(T* ptr = 0)throw() :ap(ptr){
}
auto_ptr(auto_ptr& rhs)throw():ap(rhs.release()){}
template<class Y>
auto_ptr(auto_ptr<Y>& rhs)throw():ap(rhs.rekease()){
}
auto_ptr& operator=(auto_ptr& rhs)throw(){
reset(rhs.release());
return *this;
}
template<class Y>
auto_ptr& operator=(auto_ptr<Y>& rhs)throw(){
reset(rhs.release());
return *this;
}
~auto_ptr()throw(){
delete ap;
}
T* Get() const throw(){
return ap;
}
T& operator*()const throw(){
return *ap;
}
T* operator->()const throw(){
return ap;
}
\
T* release()throw(){
T* tmp(ap);
ap = 0;
return tmp;
}
};
}
template<class Y>
struct auto_ptr_ref
{
Y* yp;
auto_ptr_ref(Y* rhs) :yp(rhs){
}
};
template<class T>
class auto_ptr{
private:
T* ap;
public:
typedef T element_type;
explicit auto_ptr(T* ptr = 0)throw() :ap(ptr){
}
auto_ptr(auto_ptr& rhs)throw():ap(rhs.release()){}
template<class Y>
auto_ptr(auto_ptr<Y>& rhs)throw():ap(rhs.rekease()){
}
auto_ptr& operator=(auto_ptr& rhs)throw(){
reset(rhs.release());
return *this;
}
template<class Y>
auto_ptr& operator=(auto_ptr<Y>& rhs)throw(){
reset(rhs.release());
return *this;
}
~auto_ptr()throw(){
delete ap;
}
T* Get() const throw(){
return ap;
}
T& operator*()const throw(){
return *ap;
}
T* operator->()const throw(){
return ap;
}
\
T* release()throw(){
T* tmp(ap);
ap = 0;
return tmp;
}
};
}
0 0
- auto_ptr实现原型
- auto_ptr实现
- auto_ptr实现
- auto_ptr 的一个实现
- auto_ptr的简单实现
- auto_ptr源码实现
- STL---auto_ptr实现
- auto_ptr实现原理
- auto_ptr的简单实现
- 应用auto_ptr, singleton的实现
- 由auto_ptr的实现说起。
- More Effective中auto_ptr实现
- 简单实现auto_ptr,shared_ptr,weak_ptr
- auto_ptr的实现与剖析
- 模拟实现auto_ptr,scoped_ptr,shardptr
- auto_ptr:
- Auto_ptr
- auto_ptr
- 使用 SELECT 查询语句拼接 迁移表至其他表空间的 SQL 脚本 语句
- IBM服务器的操作系统安装
- 飞飞天气隐私策略
- 如何撰写世界一流的子弹杀死,不管是什么为您提供!
- C++习题 复数类--重载运算符+,-,*,/
- auto_ptr实现原型
- windows下使用git管理github项目
- 得到某个表的某个字段的最大值(Oracle与Mysql的区别)
- web页面中通过js方法回调部分native的功能出现错误 Object [object Object] has no method 'openI***e' at null:1
- 纠结的Python2.7编码与os.walk()函数的目录参数
- grails找不到数据库连接类
- TCP/IP(5.1)DNS查询过程
- 高性能 TCP & UDP 通信框架 HP-Socket v3.2.2 正式发布
- 如何成为防弹从批判