All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
shared_ptr.h
Go to the documentation of this file.
1 /*
2  -------------------------------------------------------------------
3 
4  Copyright (C) 2011-2014, Andrew W. Steiner
5 
6  This file is part of O2scl.
7 
8  O2scl is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version.
12 
13  O2scl is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with O2scl. If not, see <http://www.gnu.org/licenses/>.
20 
21  -------------------------------------------------------------------
22 */
23 #ifndef O2SCL_SHARED_PTR_H
24 #define O2SCL_SHARED_PTR_H
25 
26 /** \file shared_ptr.h
27  \brief File defining \ref o2scl::o2_shared_ptr
28 */
29 
30 #ifndef DOXYGEN_NO_O2NS
31 namespace o2scl {
32 #endif
33 
34 #ifdef DOXYGEN
35 
36  /** \brief A struct to provide the shared_ptr type
37 
38  This object exists in order to provide the shared_ptr template
39  type used in \o2. The full specification of a shared pointer
40  in \o2 for an object of type \c T is thus
41  \verbatim
42  o2scl::o2_shared_ptr<T>::type
43  \endverbatim
44  In a default \o2 installation, \ref type (as given below)
45  is a typedef of
46  \verbatim
47  std::tr1::shared_ptr<T>
48  \endverbatim
49  Ifs <tt>O2SCL_HAVE_BOOST</tt>
50  is defined, then it is a typedef of
51  \verbatim
52  boost::shared_ptr<T>
53  \endverbatim
54 
55  See also the discussion at http://www.gotw.ca/gotw/079.htm . This
56  struct won't be necessary when C++ allows template typedef's as
57  part of the C++11 standard http://en.wikipedia.org/wiki/C%2B%2B11
58  , but very few compilers have implemented this standard yet.
59  */
60  template<class T> struct o2_shared_ptr {
61  /// The actual shared_ptr type
62  typedef std::tr1::shared_ptr<T> type;
63  };
64 
65 #endif
66 
67 #ifndef DOXYGEN_NO_O2NS
68 }
69 #endif
70 
71 // -------------------------------------------------------------------
72 // Define the o2_shared_ptr struct according to the installation settings
73 
74 // AWS - 11/29/11: I can't remember if the #include statements have
75 // to be outside the o2scl namespace, but I make sure they're
76 // outside just in case it matters.
77 
78 #ifndef O2SCL_NO_TR1_MEMORY
79 
80 #include <tr1/memory>
81 namespace o2scl {
82  template<class T> struct o2_shared_ptr {
83  typedef std::tr1::shared_ptr<T> type;
84  };
85 }
86 
87 #else
88 
89 #include <boost/shared_ptr.hpp>
90 namespace o2scl {
91  template<class T> struct o2_shared_ptr {
92  typedef boost::shared_ptr<T> type;
93  };
94 }
95 
96 // end of if O2SCL_NO_TR1_MEMORY
97 #endif
98 
99 // -------------------------------------------------------------------
100 
101 // end of ifdef O2SCL_SHARED_PTR_H
102 #endif
std::tr1::shared_ptr< T > type
The actual shared_ptr type.
Definition: shared_ptr.h:62
A struct to provide the shared_ptr type.
Definition: shared_ptr.h:60

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).
Hosted at Get Object-oriented Scientific Computing
Lib at SourceForge.net. Fast, secure and Free Open Source software
downloads..