auto_ptr.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 #ifndef LIBMESH_AUTO_PTR_H
19 #define LIBMESH_AUTO_PTR_H
20 
21 // libMesh includes
22 #include "libmesh/libmesh_config.h"
23 
24 // C++ includes
25 #include <memory>
26 
27 // We still provide the UniquePtr alias for backwards compatibility,
28 // but it should now be considered deprecated and users should just
29 // use std::unique_ptr instead.
30 namespace libMesh
31 {
32 template<typename T>
33 using UniquePtr = std::unique_ptr<T>;
34 }
35 
36 // Set up the libmesh_make_unique macro. We don't yet require C++14, so this is a C++11 based workaround.
37 #ifdef LIBMESH_HAVE_CXX14_MAKE_UNIQUE
38 
39 #define libmesh_make_unique std::make_unique
40 
41 #else
42 namespace libMesh
43 {
44 template<typename T, typename... Args>
45 std::unique_ptr<T> make_unique(Args &&... args)
46 {
47  return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
48 }
49 }
50 #define libmesh_make_unique make_unique
51 
52 #endif
53 
54 #endif // LIBMESH_AUTO_PTR_H
std::unique_ptr< T > make_unique(Args &&...args)
Definition: auto_ptr.h:45
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:33