YSTest: yref.hpp 源文件

YSTest PreAlpha_b400_20130424 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

全部 类 命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义 组 页
yref.hpp
浏览该文件的文档.
1 ﻿/*
2 Copyright (C) by Franksoft 2010 - 2012.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
28 #ifndef INCLUDED_ADAPTOR_YREF_HPP_
29 #define INCLUDED_ADAPTOR_YREF_HPP_ 1
30
31 #include "yadaptor.h"
32 #include <utility>
33 #include <ystdex/memory.hpp>
34
35 YSL_BEGIN
36
37 using std::bad_weak_ptr;
38 using std::const_pointer_cast;
39 using std::dynamic_pointer_cast;
40 using std::enable_shared_from_this;
41 using std::get_deleter;
43 using ystdex::make_shared;
45 using ystdex::make_unique;
46 using ystdex::raw;
47 using ystdex::reset;
48 using ystdex::share_raw;
49 using std::shared_ptr;
50 using std::static_pointer_cast;
51 using ystdex::unique_raw;
52 using std::unique_ptr;
53 using std::weak_ptr;
54
55
62 template<typename _type>
63 inline bool
64 reset(_type*& p) ynothrow
65 {
66 bool b(p);
67
68 ydelete(p);
69 p = nullptr;
70 return b;
71 }
73
78 template<typename _type>
79 bool
80 operator==(const shared_ptr<_type>& sp, _type* p)
81 {
82 return sp.get() == p;
83 }
88 template<typename _type>
89 bool
90 operator==(shared_ptr<_type>&& sp, _type* p)
91 {
92 return sp.get() == p;
93 }
94
99 template<typename _type>
100 bool
101 operator!=(const shared_ptr<_type>& sp, _type* p)
102 {
103 return sp.get() != p;
104 }
109 template<typename _type>
110 bool
111 operator!=(shared_ptr<_type>&& sp, _type* p)
112 {
113 return sp.get() != p;
114 }
115
116 YSL_END
117
118 #endif
119