x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
shared_ptr_nmt_132.hpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\references\boost_1_35_0\boost\serialization\detail\shared_ptr_nmt_132.hpp
旋转
特效
属性
历史版本
#ifndef BOOST_DETAIL_SHARED_PTR_NMT_132_HPP_INCLUDED #define BOOST_DETAIL_SHARED_PTR_NMT_132_HPP_INCLUDED // // detail/shared_ptr_nmt.hpp - shared_ptr.hpp without member templates // // (C) Copyright Greg Colvin and Beman Dawes 1998, 1999. // Copyright (c) 2001, 2002 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // See http://www.boost.org/libs/smart_ptr/shared_ptr.htm for documentation. // #include
#include
#include
#include
#ifndef BOOST_NO_AUTO_PTR # include
// for std::auto_ptr #endif #include
// for std::swap #include
// for std::less #include
// for std::bad_alloc namespace boost { template
class shared_ptr { private: typedef detail::atomic_count count_type; public: typedef T element_type; typedef T value_type; explicit shared_ptr(T * p = 0): px(p) { #ifndef BOOST_NO_EXCEPTIONS try // prevent leak if new throws { pn = new count_type(1); } catch(...) { boost::checked_delete(p); throw; } #else pn = new count_type(1); if(pn == 0) { boost::checked_delete(p); boost::throw_exception(std::bad_alloc()); } #endif } ~shared_ptr() { if(--*pn == 0) { boost::checked_delete(px); delete pn; } } shared_ptr(shared_ptr const & r): px(r.px) // never throws { pn = r.pn; ++*pn; } shared_ptr & operator=(shared_ptr const & r) { shared_ptr(r).swap(*this); return *this; } #ifndef BOOST_NO_AUTO_PTR explicit shared_ptr(std::auto_ptr
& r) { pn = new count_type(1); // may throw px = r.release(); // fix: moved here to stop leak if new throws } shared_ptr & operator=(std::auto_ptr
& r) { shared_ptr(r).swap(*this); return *this; } #endif void reset(T * p = 0) { BOOST_ASSERT(p == 0 || p != px); shared_ptr(p).swap(*this); } T & operator*() const // never throws { BOOST_ASSERT(px != 0); return *px; } T * operator->() const // never throws { BOOST_ASSERT(px != 0); return px; } T * get() const // never throws { return px; } long use_count() const // never throws { return *pn; } bool unique() const // never throws { return *pn == 1; } void swap(shared_ptr
& other) // never throws { std::swap(px, other.px); std::swap(pn, other.pn); } private: T * px; // contained pointer count_type * pn; // ptr to reference counter }; template
inline bool operator==(shared_ptr
const & a, shared_ptr
const & b) { return a.get() == b.get(); } template
inline bool operator!=(shared_ptr
const & a, shared_ptr
const & b) { return a.get() != b.get(); } template
inline bool operator<(shared_ptr
const & a, shared_ptr
const & b) { return std::less
()(a.get(), b.get()); } template
void swap(shared_ptr
& a, shared_ptr
& b) { a.swap(b); } // get_pointer() enables boost::mem_fn to recognize shared_ptr template
inline T * get_pointer(shared_ptr
const & p) { return p.get(); } } // namespace boost #endif // #ifndef BOOST_DETAIL_SHARED_PTR_NMT_132_HPP_INCLUDED
shared_ptr_nmt_132.hpp
网页地址
文件地址
上一页
4/5
下一页
下载
( 3 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.