Classes | Functions
value_ptr_test_3.cc File Reference
#include "cetlib/value_ptr.h"
#include <cassert>
#include <memory>

Go to the source code of this file.

Classes

class  simple_base
 

Functions

int main ()
 

Function Documentation

int main ( void  )

Definition at line 55 of file value_ptr_test_3.cc.

56 {
57  assert(simple_base::n_alive == 0);
58  {
60  assert(simple_base::n_alive == 1);
62  assert(simple_base::n_alive == 2);
63 
64  assert(*a == *b);
65  assert(a->isSame(*b) == false);
66  } // a and b destroyed
67  assert(simple_base::n_alive == 0);
68 
69  {
70  std::unique_ptr<simple_base> c(new simple_base(11));
71  std::unique_ptr<simple_base> d(new simple_base(11));
72  simple_base* pc = c.get();
73  simple_base* pd = d.get();
74  assert(pc != 0);
75  assert(pd != 0);
76 
77  cet::value_ptr<simple_base> e(c.release());
78  assert(c.get() == 0);
79  assert(*d == *e);
80  assert(e.operator->() == pc);
81 
83  if (f)
84  assert(0);
85  else {
86  }
87  f.reset(d.release());
88  assert(d.get() == 0);
89  assert(*e == *f);
90  assert(f.operator->() == pd);
91  if (f) {
92  } else
93  assert(0);
94 
95  assert(simple_base::n_alive == 2);
96  assert(simple_base::n_born == 4);
97  }
98  assert(simple_base::n_alive == 0);
99  assert(simple_base::n_born == 4);
100 }
const double e
const double a
static int n_alive
static bool * b
Definition: config.cpp:1043
static int n_born