Milena (Olena)
User documentation 2.0a Id
Main Page
Related Pages
Modules
Namespaces
Classes
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerator
Groups
Pages
exact.cc
1
// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
2
// Laboratory (LRDE)
3
//
4
// This file is part of Olena.
5
//
6
// Olena is free software: you can redistribute it and/or modify it under
7
// the terms of the GNU General Public License as published by the Free
8
// Software Foundation, version 2 of the License.
9
//
10
// Olena is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
// General Public License for more details.
14
//
15
// You should have received a copy of the GNU General Public License
16
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
17
//
18
// As a special exception, you may use this file as part of a free
19
// software project without restriction. Specifically, if other files
20
// instantiate templates or use macros or inline functions from this
21
// file, or you compile this file and link it with other files to produce
22
// an executable, this file does not by itself cause the resulting
23
// executable to be covered by the GNU General Public License. This
24
// exception does not however invalidate any other reasons why the
25
// executable file might be covered by the GNU General Public License.
26
27
#include <typeinfo>
28
#include <mln/core/routine/exact.hh>
29
30
31
32
struct
test :
mln::Object
< test >
33
{
34
};
35
36
37
namespace
mln
38
{
39
40
template
<
typename
E>
41
struct
Base : Object<E>
42
{
43
void
m()
44
{
45
int
** i = exact(
this
)->m_impl();
46
(void) i;
47
}
48
void
m()
const
49
{
50
int
* i = exact(
this
)->m_impl();
51
(void) i;
52
}
53
};
54
55
struct
concrete : Base< concrete >
56
{
57
int
** m_impl() {
return
0; }
58
int
* m_impl()
const
{
return
0; }
59
};
60
61
}
62
63
64
int
main()
65
{
66
using namespace
mln;
67
68
{
69
70
concrete c;
71
Base<concrete>& b = c;
72
b.m();
73
const
Base<concrete>& bb = c;
74
bb.m();
75
76
}
77
78
79
// -----------------------------------
80
81
// test t;
82
// Object<test>& t_ = t;
83
// mln_assertion(typeid(exact(t_)).name() == typeid(exact(t)).name());
84
85
// {
86
// int i;
87
// exact(i); // `int' from `float'
88
// exact(&i); // `int *' from `const double'
89
// }
90
// {
91
// const int j = 0;
92
// exact(j); // `int' from `const double'
93
// exact(&j); // `const int *' from `const double
94
// }
95
96
// {
97
// int i;
98
// int& j = i;
99
// exact(j); // `int' from `float'
100
// exact(&j); // `int *' from `const double'
101
// }
102
// {
103
// int i;
104
// const int& j = i;
105
// exact(j); // `int' from `const double'
106
// exact(&j); // `const int *' from `const double'
107
// }
108
109
// {
110
// int* i;
111
// exact(i); // `int *' from `float'
112
// exact(*i); // `int' from `float'
113
// int *const j = 0;
114
// exact(j); // `int *' from `const double'
115
// exact(*j); `int' from `float'
116
// }
117
118
// {
119
// const int* i;
120
// exact(i); // `const int *' from `float'
121
// exact(*i); // `int' from `const double'
122
// const int *const j = 0;
123
// exact(j); // `const int *' from `const double'
124
// exact(*j); `int' from `const double'
125
// }
126
127
128
// -----------------------------------
129
130
131
// {
132
// int i;
133
// exact(&i); // `int *' from `const double'
134
// }
135
// {
136
// const int j = 0;
137
// exact(j); // `int' from `const double'
138
// exact(&j); // `const int *' from `const double
139
// }
140
141
// {
142
// int i;
143
// int& j = i;
144
// exact(&j); // `int *' from `const double'
145
// }
146
// {
147
// int i;
148
// const int& j = i;
149
// exact(j); // `int' from `const double'
150
// exact(&j); // `const int *' from `const double'
151
// }
152
153
// {
154
// int *const j = 0;
155
// exact(j); // `int *' from `const double'
156
// }
157
158
// {
159
// const int* i;
160
// exact(*i); // `int' from `const double'
161
// const int *const j = 0;
162
// exact(j); // `const int *' from `const double'
163
// exact(*j); // `int' from `const double'
164
// }
165
166
167
// -----------------------------------
168
169
170
// {
171
// int* i;
172
// exact(i);
173
// }
174
175
// {
176
// int i;
177
// exact(i); // `int' from `float'
178
// }
179
180
// {
181
// int i;
182
// int& j = i;
183
// exact(j); // `int' from `float'
184
// }
185
186
// {
187
// int* i;
188
// exact(i); // `int *' from `float'
189
// exact(*i); // `int' from `float'
190
// int *const j = 0;
191
// exact(*j); // `int' from `float'
192
// }
193
194
// {
195
// const int* i;
196
// exact(i); // `const int *' from `float'
197
// }
198
199
}
tests
core
routine
exact.cc
Generated on Thu Nov 8 2012 10:58:04 for Milena (Olena) by
1.8.2-20120930