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 namespace std _GLIBCXX_VISIBILITY(default)
00055 {
00056 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00057
00058
00059
00060
00061
00062
00063
00064
00065 template<typename _Tp>
00066 class allocator;
00067
00068
00069 template<>
00070 class allocator<void>
00071 {
00072 public:
00073 typedef size_t size_type;
00074 typedef ptrdiff_t difference_type;
00075 typedef void* pointer;
00076 typedef const void* const_pointer;
00077 typedef void value_type;
00078
00079 template<typename _Tp1>
00080 struct rebind
00081 { typedef allocator<_Tp1> other; };
00082 };
00083
00084
00085
00086
00087
00088
00089
00090
00091 template<typename _Tp>
00092 class allocator: public __glibcxx_base_allocator<_Tp>
00093 {
00094 public:
00095 typedef size_t size_type;
00096 typedef ptrdiff_t difference_type;
00097 typedef _Tp* pointer;
00098 typedef const _Tp* const_pointer;
00099 typedef _Tp& reference;
00100 typedef const _Tp& const_reference;
00101 typedef _Tp value_type;
00102
00103 template<typename _Tp1>
00104 struct rebind
00105 { typedef allocator<_Tp1> other; };
00106
00107 allocator() throw() { }
00108
00109 allocator(const allocator& __a) throw()
00110 : __glibcxx_base_allocator<_Tp>(__a) { }
00111
00112 template<typename _Tp1>
00113 allocator(const allocator<_Tp1>&) throw() { }
00114
00115 ~allocator() throw() { }
00116
00117
00118 };
00119
00120 template<typename _T1, typename _T2>
00121 inline bool
00122 operator==(const allocator<_T1>&, const allocator<_T2>&)
00123 { return true; }
00124
00125 template<typename _Tp>
00126 inline bool
00127 operator==(const allocator<_Tp>&, const allocator<_Tp>&)
00128 { return true; }
00129
00130 template<typename _T1, typename _T2>
00131 inline bool
00132 operator!=(const allocator<_T1>&, const allocator<_T2>&)
00133 { return false; }
00134
00135 template<typename _Tp>
00136 inline bool
00137 operator!=(const allocator<_Tp>&, const allocator<_Tp>&)
00138 { return false; }
00139
00140
00141
00142
00143 #if _GLIBCXX_EXTERN_TEMPLATE
00144 extern template class allocator<char>;
00145 extern template class allocator<wchar_t>;
00146 #endif
00147
00148
00149 #undef __glibcxx_base_allocator
00150
00151
00152 template<typename _Alloc, bool = __is_empty(_Alloc)>
00153 struct __alloc_swap
00154 { static void _S_do_it(_Alloc&, _Alloc&) { } };
00155
00156 template<typename _Alloc>
00157 struct __alloc_swap<_Alloc, false>
00158 {
00159 static void
00160 _S_do_it(_Alloc& __one, _Alloc& __two)
00161 {
00162
00163 if (__one != __two)
00164 swap(__one, __two);
00165 }
00166 };
00167
00168
00169 template<typename _Alloc, bool = __is_empty(_Alloc)>
00170 struct __alloc_neq
00171 {
00172 static bool
00173 _S_do_it(const _Alloc&, const _Alloc&)
00174 { return false; }
00175 };
00176
00177 template<typename _Alloc>
00178 struct __alloc_neq<_Alloc, false>
00179 {
00180 static bool
00181 _S_do_it(const _Alloc& __one, const _Alloc& __two)
00182 { return __one != __two; }
00183 };
00184
00185 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00186
00187
00188
00189
00190
00191
00192 template<typename _Tp,
00193 bool = __has_trivial_copy(typename _Tp::value_type)>
00194 struct __shrink_to_fit
00195 { static void _S_do_it(_Tp&) { } };
00196
00197 template<typename _Tp>
00198 struct __shrink_to_fit<_Tp, true>
00199 {
00200 static void
00201 _S_do_it(_Tp& __v)
00202 {
00203 __try
00204 { _Tp(__v).swap(__v); }
00205 __catch(...) { }
00206 }
00207 };
00208
00209
00210
00211 struct allocator_arg_t { };
00212
00213 constexpr allocator_arg_t allocator_arg = allocator_arg_t();
00214
00215 _GLIBCXX_HAS_NESTED_TYPE(allocator_type)
00216
00217 template<typename _Tp, typename _Alloc,
00218 bool = __has_allocator_type<_Tp>::value>
00219 struct __uses_allocator_helper
00220 : public false_type { };
00221
00222 template<typename _Tp, typename _Alloc>
00223 struct __uses_allocator_helper<_Tp, _Alloc, true>
00224 : public integral_constant<bool, is_convertible<_Alloc,
00225 typename _Tp::allocator_type>::value>
00226 { };
00227
00228
00229 template<typename _Tp, typename _Alloc>
00230 struct uses_allocator
00231 : public integral_constant<bool,
00232 __uses_allocator_helper<_Tp, _Alloc>::value>
00233 { };
00234
00235 #endif
00236
00237 _GLIBCXX_END_NAMESPACE_VERSION
00238 }
00239
00240 #endif