STXXL  1.4-dev
 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 #include <memory>
19 #include <stxxl/bits/namespace.h>
20 
22 
23 template <class Type>
25 #if __cplusplus >= 201103L && ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40400)
26  typedef std::unique_ptr<Type> result;
27 #else
28  // auto_ptr is inherently broken and is deprecated by unique_ptr in c++0x
29  typedef std::auto_ptr<Type> result;
30 #endif
31 };
32 
34 
35 #if defined(__GNUG__) && ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) == 30400)
36 
37 namespace workaround_gcc_3_4 {
38 
39 // std::swap in gcc 3.4 is broken, tmp is declared const there
40 template <typename Type>
41 inline void
42 swap(Type& a, Type& b)
43 {
44  // concept requirements
45  __glibcxx_function_requires(_SGIAssignableConcept<Type>)
46 
47  Type tmp = a;
48  a = b;
49  b = tmp;
50 }
51 
52 } // namespace workaround_gcc_3_4
53 
54 namespace std {
55 
56 // overload broken std::swap<auto_ptr> to call a working swap()
57 template <typename Type>
58 inline void swap(std::auto_ptr<Type>& a, std::auto_ptr<Type>& b)
59 {
60  workaround_gcc_3_4::swap(a, b);
61 }
62 
63 } // namespace std
64 
65 #endif
66 
67 #endif // !STXXL_COMPAT_UNIQUE_PTR_HEADER
std::auto_ptr< Type > result
Definition: unique_ptr.h:29
#define STXXL_BEGIN_NAMESPACE
Definition: namespace.h:16
#define STXXL_END_NAMESPACE
Definition: namespace.h:17