Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #ifndef _ALLOCATOR_H
00045 #define _ALLOCATOR_H 1
00046
00047
00048 #include <bits/c++allocator.h>
00049
00050 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00051 #include <type_traits>
00052 #endif
00053
00054 _GLIBCXX_BEGIN_NAMESPACE(std)
00055
00056
00057
00058
00059
00060
00061
00062
00063 template<typename _Tp>
00064 class allocator;
00065
00066
00067 template<>
00068 class allocator<void>
00069 {
00070 public:
00071 typedef size_t size_type;
00072 typedef ptrdiff_t difference_type;
00073 typedef void* pointer;
00074 typedef const void* const_pointer;
00075 typedef void value_type;
00076
00077 template<typename _Tp1>
00078 struct rebind
00079 { typedef allocator<_Tp1> other; };
00080 };
00081
00082
00083
00084
00085
00086
00087
00088
00089 template<typename _Tp>
00090 class allocator: public __glibcxx_base_allocator<_Tp>
00091 {
00092 public:
00093 typedef size_t size_type;
00094 typedef ptrdiff_t difference_type;
00095 typedef _Tp* pointer;
00096 typedef const _Tp* const_pointer;
00097 typedef _Tp& reference;
00098 typedef const _Tp& const_reference;
00099 typedef _Tp value_type;
00100
00101 template<typename _Tp1>
00102 struct rebind
00103 { typedef allocator<_Tp1> other; };
00104
00105 allocator() throw() { }
00106
00107 allocator(const allocator& __a) throw()
00108 : __glibcxx_base_allocator<_Tp>(__a) { }
00109
00110 template<typename _Tp1>
00111 allocator(const allocator<_Tp1>&) throw() { }
00112
00113 ~allocator() throw() { }
00114
00115
00116 };
00117
00118 template<typename _T1, typename _T2>
00119 inline bool
00120 operator==(const allocator<_T1>&, const allocator<_T2>&)
00121 { return true; }
00122
00123 template<typename _Tp>
00124 inline bool
00125 operator==(const allocator<_Tp>&, const allocator<_Tp>&)
00126 { return true; }
00127
00128 template<typename _T1, typename _T2>
00129 inline bool
00130 operator!=(const allocator<_T1>&, const allocator<_T2>&)
00131 { return false; }
00132
00133 template<typename _Tp>
00134 inline bool
00135 operator!=(const allocator<_Tp>&, const allocator<_Tp>&)
00136 { return false; }
00137
00138
00139
00140
00141 #if _GLIBCXX_EXTERN_TEMPLATE
00142 extern template class allocator<char>;
00143 extern template class allocator<wchar_t>;
00144 #endif
00145
00146
00147 #undef __glibcxx_base_allocator
00148
00149
00150 template<typename _Alloc, bool = __is_empty(_Alloc)>
00151 struct __alloc_swap
00152 { static void _S_do_it(_Alloc&, _Alloc&) { } };
00153
00154 template<typename _Alloc>
00155 struct __alloc_swap<_Alloc, false>
00156 {
00157 static void
00158 _S_do_it(_Alloc& __one, _Alloc& __two)
00159 {
00160
00161 if (__one != __two)
00162 swap(__one, __two);
00163 }
00164 };
00165
00166
00167 template<typename _Alloc, bool = __is_empty(_Alloc)>
00168 struct __alloc_neq
00169 {
00170 static bool
00171 _S_do_it(const _Alloc&, const _Alloc&)
00172 { return false; }
00173 };
00174
00175 template<typename _Alloc>
00176 struct __alloc_neq<_Alloc, false>
00177 {
00178 static bool
00179 _S_do_it(const _Alloc& __one, const _Alloc& __two)
00180 { return __one != __two; }
00181 };
00182
00183 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00184
00185
00186
00187
00188
00189
00190 template<typename _Tp,
00191 bool = __has_trivial_copy(typename _Tp::value_type)>
00192 struct __shrink_to_fit
00193 { static void _S_do_it(_Tp&) { } };
00194
00195 template<typename _Tp>
00196 struct __shrink_to_fit<_Tp, true>
00197 {
00198 static void
00199 _S_do_it(_Tp& __v)
00200 {
00201 __try
00202 { _Tp(__v).swap(__v); }
00203 __catch(...) { }
00204 }
00205 };
00206
00207
00208
00209 struct allocator_arg_t { };
00210
00211 static const allocator_arg_t allocator_arg = allocator_arg_t();
00212
00213 _GLIBCXX_HAS_NESTED_TYPE(allocator_type)
00214
00215 template<typename _Tp, typename _Alloc,
00216 bool = __has_allocator_type<_Tp>::value>
00217 struct __uses_allocator_helper
00218 : public false_type { };
00219
00220 template<typename _Tp, typename _Alloc>
00221 struct __uses_allocator_helper<_Tp, _Alloc, true>
00222 : public integral_constant<bool, is_convertible<_Alloc,
00223 typename _Tp::allocator_type>::value>
00224 { };
00225
00226
00227 template<typename _Tp, typename _Alloc>
00228 struct uses_allocator
00229 : public integral_constant<bool,
00230 __uses_allocator_helper<_Tp, _Alloc>::value>
00231 { };
00232
00233 #endif
00234
00235 _GLIBCXX_END_NAMESPACE
00236
00237 #endif