Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
cetlib
cetlib
test
exempt_ptr_test.cc
Go to the documentation of this file.
1
#include "
cetlib/exempt_ptr.h
"
2
#include <cstdlib>
3
4
using
cet::exempt_ptr
;
5
using
cet::make_exempt_ptr
;
6
7
void
8
ensure
(
int
which,
bool
claim)
9
{
10
if
(not claim)
11
std::exit(which);
12
}
13
14
int
15
main
()
16
{
17
{
18
exempt_ptr<int>
p
;
19
ensure
(11, !p);
20
ensure
(12, p ==
nullptr
);
21
ensure
(13,
nullptr
== p);
22
ensure
(14, p == 0);
23
ensure
(15, 0 == p);
24
}
25
26
{
// non-const => const
27
int
*
p
=
new
int
(0);
28
exempt_ptr<int const>
ep(p);
29
}
30
31
{
32
exempt_ptr<double const>
p
=
make_exempt_ptr
(
new
double
(42.0));
33
ensure
(21, p !=
nullptr
);
34
ensure
(22,
nullptr
!= p);
35
ensure
(23, *p == 42.0);
36
}
37
38
#if 0
39
{
// const => non-const (ought fail to compile)
40
int
const
*
p
=
new
int
(0);
41
exempt_ptr<int>
ep(p);
42
}
43
#endif // 0
44
45
{
46
exempt_ptr<int>
p
(
new
int
(16));
47
ensure
(31, p !=
nullptr
);
48
ensure
(32,
nullptr
!= p);
49
ensure
(33, *p == 16);
50
51
exempt_ptr<int>
q(p);
52
ensure
(34, p == q);
53
ensure
(35, *p == *q);
54
55
p.
reset
(
new
int
(0));
56
return
*
p
;
57
}
58
59
}
// main()
cet::exempt_ptr::reset
constexpr void reset(pointer t=nullptr) noexcept
Definition:
exempt_ptr.h:168
cet::make_exempt_ptr
constexpr exempt_ptr< E > make_exempt_ptr(E *) noexcept
test.p
p
Definition:
test.py:223
ensure
void ensure(int which, bool claim)
Definition:
exempt_ptr_test.cc:8
keras_to_tensorflow.int
int
Definition:
keras_to_tensorflow.py:69
cet::exempt_ptr
Definition:
exempt_ptr.h:38
main
int main()
Definition:
exempt_ptr_test.cc:15
exempt_ptr.h
Generated by
1.8.11