allocator.h
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 _GLIBCXX_BEGIN_NAMESPACE(std)
00051
00052
00053
00054
00055
00056
00057
00058
00059 template<typename _Tp>
00060 class allocator;
00061
00062
00063 template<>
00064 class allocator<void>
00065 {
00066 public:
00067 typedef size_t size_type;
00068 typedef ptrdiff_t difference_type;
00069 typedef void* pointer;
00070 typedef const void* const_pointer;
00071 typedef void value_type;
00072
00073 template<typename _Tp1>
00074 struct rebind
00075 { typedef allocator<_Tp1> other; };
00076 };
00077
00078
00079
00080
00081
00082
00083
00084
00085 template<typename _Tp>
00086 class allocator: public __glibcxx_base_allocator<_Tp>
00087 {
00088 public:
00089 typedef size_t size_type;
00090 typedef ptrdiff_t difference_type;
00091 typedef _Tp* pointer;
00092 typedef const _Tp* const_pointer;
00093 typedef _Tp& reference;
00094 typedef const _Tp& const_reference;
00095 typedef _Tp value_type;
00096
00097 template<typename _Tp1>
00098 struct rebind
00099 { typedef allocator<_Tp1> other; };
00100
00101 allocator() throw() { }
00102
00103 allocator(const allocator& __a) throw()
00104 : __glibcxx_base_allocator<_Tp>(__a) { }
00105
00106 template<typename _Tp1>
00107 allocator(const allocator<_Tp1>&) throw() { }
00108
00109 ~allocator() throw() { }
00110
00111
00112 };
00113
00114 template<typename _T1, typename _T2>
00115 inline bool
00116 operator==(const allocator<_T1>&, const allocator<_T2>&)
00117 { return true; }
00118
00119 template<typename _Tp>
00120 inline bool
00121 operator==(const allocator<_Tp>&, const allocator<_Tp>&)
00122 { return true; }
00123
00124 template<typename _T1, typename _T2>
00125 inline bool
00126 operator!=(const allocator<_T1>&, const allocator<_T2>&)
00127 { return false; }
00128
00129 template<typename _Tp>
00130 inline bool
00131 operator!=(const allocator<_Tp>&, const allocator<_Tp>&)
00132 { return false; }
00133
00134
00135
00136
00137 #if _GLIBCXX_EXTERN_TEMPLATE
00138 extern template class allocator<char>;
00139 extern template class allocator<wchar_t>;
00140 #endif
00141
00142
00143 #undef __glibcxx_base_allocator
00144
00145
00146 template<typename _Alloc, bool = __is_empty(_Alloc)>
00147 struct __alloc_swap
00148 { static void _S_do_it(_Alloc&, _Alloc&) { } };
00149
00150 template<typename _Alloc>
00151 struct __alloc_swap<_Alloc, false>
00152 {
00153 static void
00154 _S_do_it(_Alloc& __one, _Alloc& __two)
00155 {
00156
00157 if (__one != __two)
00158 swap(__one, __two);
00159 }
00160 };
00161
00162
00163 template<typename _Alloc, bool = __is_empty(_Alloc)>
00164 struct __alloc_neq
00165 {
00166 static bool
00167 _S_do_it(const _Alloc&, const _Alloc&)
00168 { return false; }
00169 };
00170
00171 template<typename _Alloc>
00172 struct __alloc_neq<_Alloc, false>
00173 {
00174 static bool
00175 _S_do_it(const _Alloc& __one, const _Alloc& __two)
00176 { return __one != __two; }
00177 };
00178
00179 _GLIBCXX_END_NAMESPACE
00180
00181 #endif