STXXL  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
unique_ptr.h
Go to the documentation of this file.
1 /***************************************************************************
2  * include/stxxl/bits/compat/unique_ptr.h
3  *
4  * compatibility interface to unique_ptr (C++0x), previously auto_ptr
5  *
6  * Part of the STXXL. See http://stxxl.sourceforge.net
7  *
8  * Copyright (C) 2008 Andreas Beckmann <[email protected]>
9  *
10  * Distributed under the Boost Software License, Version 1.0.
11  * (See accompanying file LICENSE_1_0.txt or copy at
12  * http://www.boost.org/LICENSE_1_0.txt)
13  **************************************************************************/
14 
15 #ifndef STXXL_COMPAT_UNIQUE_PTR_HEADER
16 #define STXXL_COMPAT_UNIQUE_PTR_HEADER
17 
18 
19 #include <memory>
20 #include <stxxl/bits/namespace.h>
21 
22 
24 
25 template <class _Tp>
27 #if defined(__GXX_EXPERIMENTAL_CXX0X__) && ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40400)
28  typedef std::unique_ptr<_Tp> result;
29 #else
30  // auto_ptr is inherently broken and is deprecated by unique_ptr in c++0x
31  typedef std::auto_ptr<_Tp> result;
32 #endif
33 };
34 
36 
37 #if defined(__GNUG__) && ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) == 30400)
38 
39 namespace workaround_gcc_3_4 {
40 
41 // std::swap in gcc 3.4 is broken, __tmp is declared const there
42 template <typename _Tp>
43 inline void
44 swap(_Tp& __a, _Tp& __b)
45 {
46  // concept requirements
47  __glibcxx_function_requires(_SGIAssignableConcept<_Tp>)
48 
49  _Tp __tmp = __a;
50  __a = __b;
51  __b = __tmp;
52 }
53 
54 } // namespace workaround_gcc_3_4
55 
56 namespace std {
57 
58 // overload broken std::swap<auto_ptr> to call a working swap()
59 template <typename _Tp>
60 inline void swap(std::auto_ptr<_Tp>& a, std::auto_ptr<_Tp>& b)
61 {
62  workaround_gcc_3_4::swap(a, b);
63 }
64 
65 } // namespace std
66 
67 #endif
68 
69 #endif // !STXXL_COMPAT_UNIQUE_PTR_HEADER
std::auto_ptr< _Tp > result
Definition: unique_ptr.h:31
#define STXXL_BEGIN_NAMESPACE
Definition: namespace.h:16
#define STXXL_END_NAMESPACE
Definition: namespace.h:17