YSTest: base.h 源文件

YSTest PreAlpha_b700_20160611 The YSLib Test Project

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

- 文件列表
- 文件成员

base.h
浏览该文件的文档.
1 /*
2 © 2013-2015 FrankHB.
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 YB_INC_ystdex_base_h_
29 #define YB_INC_ystdex_base_h_ 1
30
31 #include "../ydef.h"
32
33 namespace ystdex
34 {
35
41 class noncopyable
42 {
43 protected:
48 yconstfn
49 noncopyable() = default;
51 ~noncopyable() = default;
52
53 public:
55 yconstfn
56 noncopyable(const noncopyable&) = delete;
61 yconstfn
62 noncopyable(noncopyable&&) = default;
63
65 noncopyable&
66 operator=(const noncopyable&) = delete;
71 noncopyable&
72 operator=(noncopyable&&) = default;
73 };
74
75
76 /*
77 \brief 不可转移对象：禁止继承此类的对象调用默认原型的转移构造函数和转移赋值操作符。
78 \warning 非虚析构。
79 \since build 373
80 */
81 class nonmovable
82 {
83 protected:
88 yconstfn
89 nonmovable() = default;
91 ~nonmovable() = default;
92
93 public:
95
96 yconstfn
98 nonmovable(const nonmovable&) = default;
100 yconstfn
101 nonmovable(nonmovable&&) = delete;
102
104 nonmovable&
105 operator=(const nonmovable&) = default;
107 nonmovable&
108 operator=(nonmovable&&) = delete;
110 };
111
112
117 class YB_API cloneable
118 {
119 public:
121 cloneable() = default;
122 #if YB_IMPL_MSCPP
123 cloneable(cloneable&&)
125 {}
126 #endif
127 cloneable(const cloneable&) = default;
130 virtual
131 ~cloneable();
132
133 virtual cloneable*
134 clone() const = 0;
135 };
136
137
144 template<typename _type>
145 struct deref_self
146 {
147 _type&
148 operator*() ynothrow
149 {
150 return *static_cast<_type*>(this);
151 }
152 const _type&
153 operator*() const ynothrow
154 {
155 return *static_cast<const _type*>(this);
156 }
157 volatile _type&
158 operator*() volatile ynothrow
159 {
160 return *static_cast<volatile _type*>(this);
161 }
162 const volatile _type&
163 operator*() const volatile ynothrow
164 {
165 return *static_cast<const volatile _type*>(this);
166 }
167 };
168
169 } // namespace ystdex;
170
171 #endif
172
ystdex::noncopyable::~noncopyable
~noncopyable()=default
protected 析构：默认实现。
ystdex::deref_self
间接操作：返回派生类自身引用。
Definition: base.h:145
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:740
ystdex::noncopyable::noncopyable
noncopyable()=default
protected 构造：默认实现。
ystdex::any_ops::clone
Definition: any.h:253
ystdex::noncopyable::operator=
noncopyable & operator=(const noncopyable &)=delete
禁止复制赋值。
YB_API
#define YB_API
YBase 应用程序编程接口：用于向库文件约定链接。
Definition: ydef.h:566
ystdex::nonmovable::operator=
nonmovable & operator=(const nonmovable &)=default
允许复制赋值。
ystdex::deref_self::operator*
volatile _type & operator*() volatile
Definition: base.h:158
ystdex
特性测试宏。
Definition: ydef.h:796
ystdex::nonmovable
Definition: base.h:81
ystdex::deref_self::operator*
_type & operator*()
Definition: base.h:148
yconstfn
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:654
ystdex::noncopyable
不可复制对象：禁止派生类调用默认原型的复制构造函数和复制赋值操作符。
Definition: base.h:41
ystdex::deref_self::operator*
const volatile _type & operator*() const volatile
Definition: base.h:163
ystdex::deref_self::operator*
const _type & operator*() const
Definition: base.h:153
ystdex::nonmovable::~nonmovable
~nonmovable()=default
protected 析构：默认实现。
ystdex::cloneable
可动态复制的抽象基类。
Definition: base.h:117
ystdex::nonmovable::nonmovable
nonmovable()=default
protected 构造：默认实现。