LRDE Tiger Compiler
1.34a $Id: 7fef12e1f5fa43449d667a0eec1d837c40fc1202 $
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
ref.hxx
Go to the documentation of this file.
1
6
#ifndef MISC_REF_HXX
7
# define MISC_REF_HXX
8
9
# include <typeinfo>
10
11
# include <
misc/ref.hh
>
12
13
namespace
misc
14
{
15
16
/*-----------------.
17
| Ctors and dtor. |
18
`-----------------*/
19
20
template
<
typename
T>
21
template
<
typename
U>
22
ref<T>::ref
(
const
ref<U>
& other)
23
:
super_type
(other)
24
{
25
}
26
27
template
<
typename
T>
28
ref<T>::ref
(
const
ref<T>
& other)
29
:
super_type
(other)
30
{
31
}
32
33
template
<
typename
T>
34
ref<T>::ref
(T* p)
35
:
super_type
(p)
36
{
37
}
38
39
template
<
typename
T>
40
ref<T>::~ref
()
41
{
42
}
43
44
45
/*---------------------.
46
| Equality operators. |
47
`---------------------*/
48
49
template
<
typename
T>
50
bool
51
ref<T>::operator==
(
const
T* other)
const
52
{
53
return
this->
get
() == other;
54
}
55
56
template
<
typename
T>
57
bool
58
ref<T>::operator!=
(
const
T* other)
const
59
{
60
return
!(*
this
== other);
61
}
62
63
64
/*--------.
65
| Casts. |
66
`--------*/
67
68
template
<
typename
T>
69
template
<
typename
U>
70
ref<U>
71
ref<T>::unsafe_cast
()
const
72
{
73
ref<U>
res;
74
(std::dynamic_pointer_cast<U,
element_type
>(*this)).swap(res);
75
return
res;
76
}
77
78
template
<
typename
T>
79
template
<
typename
U>
80
ref<U>
81
ref<T>::cast
()
const
82
{
83
if
(!this->
get
() || !this->is_a<U>())
84
throw
std::bad_cast();
85
return
unsafe_cast<U>();
86
}
87
88
template
<
typename
T>
89
template
<
typename
U>
90
bool
91
ref<T>::is_a
()
const
92
{
93
return
dynamic_cast<
U*
>
(this->
get
());
94
}
95
}
96
97
#endif // !MISC_REF_HXX
misc
ref.hxx
Generated on Wed Mar 5 2014 15:47:36 for LRDE Tiger Compiler by
1.8.1.2