Developer Documentation

MemoryInclude.hh
1 /*===========================================================================*\
2 * *
3 * OpenVolumeMesh *
4 * Copyright (C) 2011 by Computer Graphics Group, RWTH Aachen *
5 * www.openvolumemesh.org *
6 * *
7 *---------------------------------------------------------------------------*
8 * This file is part of OpenVolumeMesh. *
9 * *
10 * OpenVolumeMesh is free software: you can redistribute it and/or modify *
11 * it under the terms of the GNU Lesser General Public License as *
12 * published by the Free Software Foundation, either version 3 of *
13 * the License, or (at your option) any later version with the *
14 * following exceptions: *
15 * *
16 * If other files instantiate templates or use macros *
17 * or inline functions from this file, or you compile this file and *
18 * link it with other files to produce an executable, this file does *
19 * not by itself cause the resulting executable to be covered by the *
20 * GNU Lesser General Public License. This exception does not however *
21 * invalidate any other reasons why the executable file might be *
22 * covered by the GNU Lesser General Public License. *
23 * *
24 * OpenVolumeMesh is distributed in the hope that it will be useful, *
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
27 * GNU Lesser General Public License for more details. *
28 * *
29 * You should have received a copy of the GNU LesserGeneral Public *
30 * License along with OpenVolumeMesh. If not, *
31 * see <http://www.gnu.org/licenses/>. *
32 * *
33 \*===========================================================================*/
34
35 #ifndef ACG_UTILS_SMARTPOINTER_HH
36 #define ACG_UTILS_SMARTPOINTER_HH
37
38 /**********************************************
39 * Warning! This header file is duplicated in *
40 * OpenFlipper with the same header guard, as *
41 * ACG/Utils/SmartPointer.hh. *
42 * If you change this file, you should change *
43 * that file as well. *
44 **********************************************/
45
46 #include <memory>
47
48 // Default for C++ 11 and higher
49 #if ((defined(_MSC_VER) && (_MSC_VER >= 1900)) || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__))
50
51 // legacy code may depend on this define:
52 #define ACG_UNIQUE_POINTER_SUPPORTED 1
53
54 namespace ptr {
55 using std::shared_ptr;
56 using std::make_shared;
57 using std::unique_ptr;
58
59 #if __cplusplus >= 201402L
60 using std::make_unique;
61 #else
62 template<typename T, typename... Args>
63 std::unique_ptr<T>
64 make_unique(Args&&... args) {
65 return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
66 }
67 #endif // C++14
68
69 } // namespace ptr
70
71
72 #else // deprecated things
73
77 #if ( (__cplusplus >= 201103L) || (__STDC_VERSION__ >= 201112L) )
78 // C++11:
79 #include <memory>
80 namespace ptr = std;
81 #define ACG_UNIQUE_POINTER_SUPPORTED 1
82 #elif defined(__GXX_EXPERIMENTAL_CXX0X__)
83 // C++11 via -std=c++0x on gcc:
84 #include <memory>
85 namespace ptr = std;
86 #define ACG_UNIQUE_POINTER_SUPPORTED 1
87 #else
88 // C++98 and TR1:
89 #if (_MSC_VER >= 1600)
90 // VStudio 2010 supports some C++11 features
91 #include <memory>
92 namespace ptr = std;
93 #define ACG_UNIQUE_POINTER_SUPPORTED 1
94 #elif (_MSC_VER >= 1500)
95 // hope for TR1 equivalents
96 #if(_HAS_TR1)
97 #include <memory>
98 namespace ptr = std::tr1;
99 #define ACG_UNIQUE_POINTER_SUPPORTED 0
100 #else
101 #pragma warning "TR1 not available! Please install Visual Studio Service Pack 1!"
102 #endif
103 #else
104 // hope for TR1 equivalents
105 // check for clang5 but switch to tr1 if clang uses libstdc++
106 #if defined(__clang_major__) && (__clang_major__ >= 5) && !defined(__GLIBCXX__ )
107 // Mavericks special treatment
108 #include <memory>
109 namespace ptr = std;
110 #else
111 #include <tr1/memory>
112 namespace ptr = std::tr1;
113 #endif
114 #define ACG_UNIQUE_POINTER_SUPPORTED 0
115 #endif
116 #endif
117 #endif
118
119
120
121
122 #endif // ACG_UTILS_SMARTPOINTER_HH
123
std
STL namespace.