Wrapper_t.cpp
Go to the documentation of this file.
1 /*
2  *
3  * CMSSW
4  *
5  */
6 
8 
9 #include <cassert>
10 #include <iostream>
11 #include <memory>
12 #include <vector>
13 
15 {
16  public:
18  CopyNoSwappy(CopyNoSwappy const&) { /* std::cout << "copied\n"; */ }
19  CopyNoSwappy& operator=(CopyNoSwappy const&) & { /*std::cout << "assigned\n";*/ return *this;}
20  private:
21 };
22 
24 {
25  public:
27  void swap(SwappyNoCopy&) { /* std::cout << "swapped\n";*/ }
28  private:
29  SwappyNoCopy(SwappyNoCopy const&); // not implemented
30  SwappyNoCopy& operator=(SwappyNoCopy const&); // not implemented
31 };
32 
33 void work()
34 {
35  std::unique_ptr<CopyNoSwappy> thing(new CopyNoSwappy);
36  art::Wrapper<CopyNoSwappy> wrap(thing);
37 
38  std::unique_ptr<SwappyNoCopy> thing2(new SwappyNoCopy);
39  art::Wrapper<SwappyNoCopy> wrap2(thing2);
40 
41 
42  std::unique_ptr<std::vector<double> >
43  thing3(new std::vector<double>(10,2.2));
44  assert(thing3->size() == 10);
45 
46  art::Wrapper<std::vector<double> > wrap3(thing3);
47  assert(wrap3->size() == 10);
48  assert(thing3.get() == 0);
49 }
50 
51 int main()
52 {
53  int rc = 0;
54  try {
55  work();
56  }
57  catch (...) {
58  rc = 1;
59  std::cerr << "Failure: unidentified exception caught\n";
60  }
61  return rc;
62 }
CopyNoSwappy & operator=(CopyNoSwappy const &)&
Definition: Wrapper_t.cpp:19
int main()
Definition: Wrapper_t.cpp:51
void work()
Definition: Wrapper_t.cpp:33
void swap(SwappyNoCopy &)
Definition: Wrapper_t.cpp:27
CopyNoSwappy(CopyNoSwappy const &)
Definition: Wrapper_t.cpp:18