UFO: Alien Invasion
Loading...
Searching...
No Matches
autoptr.h
Go to the documentation of this file.
1
#pragma once
2
3
template
<
typename
T>
class
AutoPtr
4
{
5
public
:
6
explicit
AutoPtr
(T*
const
p = 0) :
7
p_
(p)
8
{
9
}
10
11
~AutoPtr
()
12
{
13
if
(
p_
)
14
delete
p_
;
15
}
16
17
void
deallocate
()
18
{
19
*
this
= 0;
20
}
21
22
T*
release
()
23
{
24
T*
const
p =
p_
;
25
p_
= 0;
26
return
p;
27
}
28
29
void
operator =
(T*
const
p)
30
{
31
if
(
p_
)
32
delete
p_
;
33
p_
= p;
34
}
35
36
T*
operator ->
()
const
37
{
38
return
p_
;
39
}
40
41
T&
operator *
()
const
42
{
43
return
*
p_
;
44
}
45
46
operator
bool ()
const
47
{
48
return
p_
;
49
}
50
51
operator
T* ()
const
52
{
53
return
p_
;
54
}
55
56
private
:
57
T*
p_
;
58
59
AutoPtr
(
const
AutoPtr
&);
/* no copy */
60
void
operator =
(
AutoPtr
&);
/* no assignment */
61
};
AutoPtr::AutoPtr
AutoPtr(T *const p=0)
Definition
autoptr.h:6
AutoPtr::operator->
T * operator->() const
Definition
autoptr.h:36
AutoPtr::operator=
void operator=(T *const p)
Definition
autoptr.h:29
AutoPtr::AutoPtr
AutoPtr(const AutoPtr &)
AutoPtr::p_
T * p_
Definition
autoptr.h:57
AutoPtr::~AutoPtr
~AutoPtr()
Definition
autoptr.h:11
AutoPtr::operator*
T & operator*() const
Definition
autoptr.h:41
AutoPtr::deallocate
void deallocate()
Definition
autoptr.h:17
AutoPtr::release
T * release()
Definition
autoptr.h:22
src
shared
autoptr.h
Generated on __DATE__ __TIME__ for UFO: Alien Invasion by
1.16.1