Regenerated man pages
[amule.git] / src / libs / common / SmartPtr.h
blob627976193c8623f0bf0440ac7c73c16f573c155c
1 // -*- C++ -*-
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2019 aMule Team ( admin@amule.org / http://www.amule.org )
5 //
6 // Any parts of this program derived from the xMule, lMule or eMule project,
7 // or contributed by third-party developers are copyrighted by their
8 // respective authors.
9 //
10 // This program is free software; you can redistribute it and/or modify
11 // it under the terms of the GNU General Public License as published by
12 // the Free Software Foundation; either version 2 of the License, or
13 // (at your option) any later version.
15 // This program is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
20 // You should have received a copy of the GNU General Public License
21 // along with this program; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #ifndef SMARTPTR_H
26 #define SMARTPTR_H
28 // std::auto_ptr is deprecated in C++11 and removed in C++17. We should use
29 // std::unique_ptr instead, which was introduced in C++11.
31 // Considering the above, we shall use std::unique_ptr if we're using C++11 or
32 // a later standard, and std::auto_ptr otherwise.
34 #include <memory>
36 #if __cplusplus >= 201103L
38 // It seems like Apple has (or had, hopefully) a configuration where a new
39 // clang compiler supporting C++11 is accompanied by an old c++ library not
40 // supporting std::unique_ptr.
41 // See https://stackoverflow.com/questions/31655462/no-type-named-unique-ptr-in-namespace-std-when-compiling-under-llvm-clang
42 # ifdef __clang__
43 # if __has_include(<forward_list>)
44 // either using libc++ or a libstdc++ that's
45 // new enough to have unique_ptr
46 # define HAVE_UNIQUE_PTR 1
47 # endif
48 # else
49 // not clang, assume unique_ptr available
50 # define HAVE_UNIQUE_PTR 1
51 # endif
53 #endif
55 #ifdef HAVE_UNIQUE_PTR
56 template<typename T> using CSmartPtr = std::unique_ptr<T>;
57 #else
58 # define CSmartPtr std::auto_ptr
59 # ifndef nullptr
60 # define nullptr NULL
61 # endif
62 #endif
64 #undef HAVE_UNIQUE_PTR
66 #endif /* SMARTPTR_H */