🛰️航天仿真算法库 SpaceAST
0.0.1
载入中...
搜索中...
未找到
ClonePtr.hpp
浏览该文件的文档.
1
20
21
#pragma once
22
23
#include "AstGlobal.h"
24
#include "
ScopedPtr.hpp
"
25
26
AST_NAMESPACE_BEGIN
27
36
template
<
typename
T>
37
class
ClonePtr
:
public
ScopedPtr
<T>
38
{
39
public
:
40
ClonePtr
() =
default
;
41
ClonePtr
(
const
ClonePtr
& other)
42
{
43
if
(other.get())
44
this->m_pointer = other.get()->clone();
45
}
46
ClonePtr
(
ClonePtr
&& other)
47
{
48
this->m_pointer = other.m_pointer;
49
other.m_pointer =
nullptr
;
50
}
51
ClonePtr
& operator=(
const
ClonePtr
& other)
52
{
53
if
(other.get())
54
this->reset(other.get()->clone());
55
else
56
this->reset(
nullptr
);
57
return
*
this
;
58
}
59
ClonePtr
& operator=(
ClonePtr
&& other)
60
{
61
std::swap(this->m_pointer, other.m_pointer);
62
return
*
this
;
63
}
64
ClonePtr
& operator=(T* ptr)
65
{
66
this->reset(ptr);
67
return
*
this
;
68
}
69
};
70
73
AST_NAMESPACE_END
ScopedPtr.hpp
作用域指针
ast::ClonePtr
克隆指针类
定义
ClonePtr.hpp:38
ast::ScopedPtr
作用域指针类
定义
ScopedPtr.hpp:65
src
AstUtil
RTTI
ClonePtr.hpp
制作者
1.12.0