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 
00047 #ifndef MFCSTL_INCL_MFCSTL_MEMORY_HPP_AFX_ALLOCATOR
00048 #define MFCSTL_INCL_MFCSTL_MEMORY_HPP_AFX_ALLOCATOR
00049 
00050 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00051 # define MFCSTL_VER_MFCSTL_MEMORY_HPP_AFX_ALLOCATOR_MAJOR       2
00052 # define MFCSTL_VER_MFCSTL_MEMORY_HPP_AFX_ALLOCATOR_MINOR       0
00053 # define MFCSTL_VER_MFCSTL_MEMORY_HPP_AFX_ALLOCATOR_REVISION    4
00054 # define MFCSTL_VER_MFCSTL_MEMORY_HPP_AFX_ALLOCATOR_EDIT        21
00055 #endif 
00056 
00057 
00058 
00059 
00060 
00061 
00062 
00063 
00064 
00065 
00066 
00067 
00068 
00069 #ifndef MFCSTL_INCL_MFCSTL_HPP_MFCSTL
00070 # include <mfcstl/mfcstl.hpp>
00071 #endif 
00072 #ifndef STLSOFT_INCL_STLSOFT_MEMORY_HPP_ALLOCATOR_BASE
00073 # include <stlsoft/memory/allocator_base.hpp>
00074 #endif 
00075 
00076 #ifndef STLSOFT_INCL_STDEXCEPT
00077 # define STLSOFT_INCL_STDEXCEPT
00078 # include <stdexcept>                    
00079 #endif 
00080 
00081 #ifndef STLSOFT_INCL_H_AFX
00082 # define STLSOFT_INCL_H_AFX
00083 # include <afx.h>
00084 #endif 
00085 
00086 
00087 
00088 
00089 
00090 #ifndef _MFCSTL_NO_NAMESPACE
00091 # if defined(_STLSOFT_NO_NAMESPACE) || \
00092      defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00093 
00094 namespace mfcstl
00095 {
00096 # else
00097 
00098 
00099 namespace stlsoft
00100 {
00101 
00102 namespace mfcstl_project
00103 {
00104 
00105 # endif 
00106 #endif 
00107 
00108 
00109 
00110 
00111 
00118 template <ss_typename_param_k T>
00119 class afx_allocator
00120     : public allocator_base<T, afx_allocator<T> >
00121 {
00122 private:
00123     typedef allocator_base<T, afx_allocator<T> >                    parent_class_type;
00124 public:
00126     typedef afx_allocator<T>                                        class_type;
00128     typedef ss_typename_type_k parent_class_type::value_type        value_type;
00130     typedef ss_typename_type_k parent_class_type::pointer           pointer;
00132     typedef ss_typename_type_k parent_class_type::const_pointer     const_pointer;
00134     typedef ss_typename_type_k parent_class_type::reference         reference;
00136     typedef ss_typename_type_k parent_class_type::const_reference   const_reference;
00138     typedef ss_typename_type_k parent_class_type::difference_type   difference_type;
00140     typedef ss_typename_type_k parent_class_type::size_type         size_type;
00141 
00142 public:
00143 #ifdef STLSOFT_CF_ALLOCATOR_REBIND_SUPPORT
00145     template <ss_typename_param_k U>
00146     struct rebind
00147     {
00148         typedef afx_allocator<U>                                    other;
00149     };
00150 #endif 
00151 
00152 
00153 public:
00155     afx_allocator() stlsoft_throw_0()
00156     {}
00158     afx_allocator(class_type const& rhs) stlsoft_throw_0()
00159     {}
00160 #ifdef STLSOFT_CF_ALLOCATOR_REBIND_SUPPORT
00161     template <ss_typename_param_k U>
00162     afx_allocator(afx_allocator<U> const& rhs) stlsoft_throw_0()
00163     {}
00164 #endif 
00166     ~afx_allocator() stlsoft_throw_0()
00167     {}
00168 
00169     class_type const& operator =(class_type const& rhs)
00170     {
00171         return *this;
00172     }
00173 
00174 private:
00175     friend class allocator_base<T, afx_allocator<T> >;
00176 
00177     void *do_allocate(size_type n, void const* hint)
00178     {
00179         STLSOFT_SUPPRESS_UNUSED(hint);
00180 
00181         return new BYTE[n * sizeof(value_type)];
00182     }
00183     void do_deallocate(void *pv, size_type n)
00184     {
00185         STLSOFT_SUPPRESS_UNUSED(n);
00186 
00187         delete [] static_cast<BYTE*>(pv);
00188     }
00189     void do_deallocate(void *pv)
00190     {
00191         delete [] static_cast<BYTE*>(pv);
00192     }
00193 };
00194 
00195 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00196 
00197 
00198 STLSOFT_TEMPLATE_SPECIALISATION
00199 class afx_allocator<void>
00200 {
00201 public:
00202     typedef void                    value_type;
00203     typedef afx_allocator<void>     class_type;
00204     typedef void*                   pointer;
00205     typedef void const*             const_pointer;
00206     typedef ms_ptrdiff_t            difference_type;
00207     typedef ms_size_t               size_type;
00208 
00209 #ifdef STLSOFT_CF_ALLOCATOR_REBIND_SUPPORT
00211     template <ss_typename_param_k U>
00212     struct rebind
00213     {
00214         typedef afx_allocator<U>  other;
00215     };
00216 #endif 
00217 };
00218 
00219 #endif 
00220 
00221 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00222 
00223 template <ss_typename_param_k T>
00224 inline ms_bool_t operator ==(const afx_allocator<T> &, const afx_allocator<T> &)
00225 {
00226     return ms_true_v;
00227 }
00228 
00229 template <ss_typename_param_k T>
00230 inline ms_bool_t operator !=(const afx_allocator<T> &, const afx_allocator<T> &)
00231 {
00232     return ms_false_v;
00233 }
00234 
00235 #endif 
00236 
00238 
00239 
00240 #ifdef STLSOFT_UNITTEST
00241 # include "./unittest/afx_allocator_unittest_.h"
00242 #endif 
00243 
00244 
00245 
00246 #ifndef _MFCSTL_NO_NAMESPACE
00247 # if defined(_STLSOFT_NO_NAMESPACE) || \
00248      defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00249 } 
00250 # else
00251 } 
00252 } 
00253 # endif 
00254 #endif 
00255 
00256 
00257 
00258 #endif 
00259 
00260