Loading [MathJax]/extensions/TeX/AMSsymbols.js
 Reference documentation for deal.II version 8.5.1
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
unique_ptr.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2015, 2016 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii__std_cxx11_unique_ptr_h
17 #define dealii__std_cxx11_unique_ptr_h
18 
19 
20 #include <deal.II/base/config.h>
21 
22 #ifdef DEAL_II_WITH_CXX11
23 
24 # include <memory>
25 DEAL_II_NAMESPACE_OPEN
26 namespace std_cxx11
27 {
28  using std::unique_ptr;
29 }
30 DEAL_II_NAMESPACE_CLOSE
31 
32 #else
33 
34 #include <boost/scoped_ptr.hpp>
35 #include <boost/serialization/scoped_ptr.hpp>
36 
37 
38 DEAL_II_NAMESPACE_OPEN
39 namespace std_cxx11
40 {
58  template <typename T>
59  class unique_ptr : public boost::scoped_ptr<T>
60  {
61  public:
62  unique_ptr () {}
63 
64  template<class Y>
65  explicit unique_ptr (Y *p)
66  :
67  boost::scoped_ptr<T>(p)
68  {}
69  };
70 
71 
72  template<class Archive, class T>
73  void save(Archive &ar,
74  const unique_ptr< T > &t,
75  const unsigned int version)
76  {
77  boost::serialization::save (ar, static_cast<boost::scoped_ptr<T>&>(t), version);
78  }
79 
80  template<class Archive, class T>
81  void load(Archive &ar,
82  unique_ptr< T > &t,
83  const unsigned int version)
84  {
85  boost::serialization::load (ar, static_cast<boost::scoped_ptr<T>&>(t), version);
86  }
87 
88  template<class Archive, class T>
89  void serialize(Archive &ar,
90  unique_ptr< T > &t,
91  const unsigned int version)
92  {
93  boost::serialization::serialize (ar, static_cast<boost::scoped_ptr<T>&>(t), version);
94  }
95 
96 }
97 DEAL_II_NAMESPACE_CLOSE
98 
99 #endif
100 
101 // then allow using the old namespace name instead of the new one
102 DEAL_II_NAMESPACE_OPEN
103 namespace std_cxx1x = std_cxx11;
104 DEAL_II_NAMESPACE_CLOSE
105 
106 #endif