Functions
exempt_ptr_test.cc File Reference
#include "cetlib/exempt_ptr.h"
#include <cstdlib>

Go to the source code of this file.

Functions

void ensure (int which, bool claim)
 
int main ()
 

Function Documentation

void ensure ( int  which,
bool  claim 
)

Definition at line 8 of file exempt_ptr_test.cc.

9 {
10  if (not claim)
11  std::exit(which);
12 }
int main ( void  )

Definition at line 15 of file exempt_ptr_test.cc.

16 {
17  {
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);
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()
constexpr void reset(pointer t=nullptr) noexcept
Definition: exempt_ptr.h:168
constexpr exempt_ptr< E > make_exempt_ptr(E *) noexcept
p
Definition: test.py:223
void ensure(int which, bool claim)