home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stlpt453.zip / STLport-4.5.3 / stlport / stl / _alloc.h < prev    next >
C/C++ Source or Header  |  2002-02-02  |  19KB  |  532 lines

  1. /*
  2.  *
  3.  * Copyright (c) 1996,1997
  4.  * Silicon Graphics Computer Systems, Inc.
  5.  *
  6.  * Copyright (c) 1997
  7.  * Moscow Center for SPARC Technology
  8.  *
  9.  * Copyright (c) 1999 
  10.  * Boris Fomitchev
  11.  *
  12.  * This material is provided "as is", with absolutely no warranty expressed
  13.  * or implied. Any use is at your own risk.
  14.  *
  15.  * Permission to use or copy this software for any purpose is hereby granted 
  16.  * without fee, provided the above notices are retained on all copies.
  17.  * Permission to modify the code and to distribute modified code is granted,
  18.  * provided the above notices are retained, and a notice that the code was
  19.  * modified is included with the above copyright notice.
  20.  *
  21.  */
  22.  
  23. /* NOTE: This is an internal header file, included by other STL headers.
  24.  *   You should not attempt to use it directly.
  25.  */
  26.  
  27. #ifndef _STLP_INTERNAL_ALLOC_H
  28. #define _STLP_INTERNAL_ALLOC_H
  29.  
  30. # ifndef _STLP_CSTDDEF
  31. #  include <cstddef>
  32. # endif
  33.  
  34. #if !defined (_STLP_DEBUG_H) && (defined  (_STLP_DEBUG) || defined (_STLP_ASSERTIONS))
  35. # include <stl/debug/_debug.h>
  36. #endif
  37.  
  38. # ifndef _STLP_CSTDLIB
  39. #  include <cstdlib>
  40. # endif
  41. # ifndef _STLP_CSTRING
  42. #  include <cstring>
  43. # endif
  44.  
  45. # ifndef __THROW_BAD_ALLOC
  46. #  if !defined(_STLP_USE_EXCEPTIONS)
  47. #   if !defined (_STLP_CSTDIO)
  48. #    include <cstdio>
  49. #   endif
  50. #   if !defined (_STLP_CSTDLIB)
  51. #    include <cstdlib>
  52. #   endif
  53. #   define __THROW_BAD_ALLOC puts("out of memory\n"); exit(1)
  54. #  else /* !defined(_STLP_USE_EXCEPTIONS) */
  55. #   define __THROW_BAD_ALLOC throw _STLP_STD::bad_alloc()
  56. #  endif /* !defined(_STLP_USE_EXCEPTIONS) */
  57. # endif   /* __THROW_BAD_ALLOC */
  58.  
  59. # ifndef _STLP_NEW_HEADER
  60. #  include <new>
  61. # endif
  62.  
  63. #if /* defined (_STLP_THREADS) && */ ! defined (_STLP_INTERNAL_THREADS_H)
  64. # include <stl/_threads.h>
  65. #endif
  66.  
  67. #ifndef _STLP_INTERNAL_CONSTRUCT_H
  68. # include <stl/_construct.h>
  69. #endif
  70.  
  71. #ifndef __ALLOC
  72. #   define __ALLOC __sgi_alloc
  73. #endif
  74.  
  75. # ifndef __RESTRICT
  76. #  define __RESTRICT
  77. # endif
  78.  
  79. #if defined (_STLP_THREADS) || (defined(_STLP_OWN_IOSTREAMS) && ! defined (_STLP_NO_THREADS) && ! defined (_NOTHREADS) )
  80. # define _STLP_NODE_ALLOCATOR_THREADS true
  81. #else
  82. # define _STLP_NODE_ALLOCATOR_THREADS false
  83. #endif
  84.  
  85. _STLP_BEGIN_NAMESPACE
  86.  
  87. # if defined (_STLP_USE_RAW_SGI_ALLOCATORS)
  88. template <class _Tp, class _Alloc> struct __allocator;
  89. # endif
  90.  
  91. // Malloc-based allocator.  Typically slower than default alloc below.
  92. // Typically thread-safe and more storage efficient.
  93.  
  94. typedef void (* __oom_handler_type)();
  95.  
  96. template <int __inst>
  97. class __malloc_alloc {
  98. private:
  99.   static void* _STLP_CALL _S_oom_malloc(size_t);
  100.   static __oom_handler_type __oom_handler;
  101. public:
  102.   // this one is needed for proper simple_alloc wrapping
  103.   typedef char value_type;
  104. # if defined (_STLP_MEMBER_TEMPLATE_CLASSES) && defined (_STLP_USE_RAW_SGI_ALLOCATORS)
  105.   template <class _Tp1> struct rebind {
  106.     typedef __allocator<_Tp1, __malloc_alloc<__inst> > other;
  107.   };
  108. # endif
  109.   static void* _STLP_CALL allocate(size_t __n)    {
  110.     void* __result = malloc(__n);
  111.     if (0 == __result) __result = _S_oom_malloc(__n);
  112.     return __result;
  113.   }
  114.   static void _STLP_CALL deallocate(void* __p, size_t /* __n */) { free((char*)__p); }
  115.   static __oom_handler_type _STLP_CALL set_malloc_handler(__oom_handler_type __f) {
  116.     __oom_handler_type __old = __oom_handler;
  117.     __oom_handler = __f;
  118.     return(__old);
  119.   }
  120. };
  121.  
  122.  
  123. // New-based allocator.  Typically slower than default alloc below.
  124. // Typically thread-safe and more storage efficient.
  125. class _STLP_CLASS_DECLSPEC __new_alloc {
  126. public:
  127.   // this one is needed for proper simple_alloc wrapping
  128.   typedef char value_type;
  129. # if defined (_STLP_MEMBER_TEMPLATE_CLASSES) &&  defined(_STLP_USE_RAW_SGI_ALLOCATORS)
  130.   template <class _Tp1> struct rebind {
  131.     typedef __allocator<_Tp1, __new_alloc > other;
  132.   };
  133. # endif
  134.   static void* _STLP_CALL  allocate(size_t __n) {  return __stl_new(__n); }
  135.   static void _STLP_CALL deallocate(void* __p, size_t) { __stl_delete(__p); }
  136. };
  137.  
  138.  
  139. // Allocator adaptor to check size arguments for debugging.
  140. // Reports errors using assert.  Checking can be disabled with
  141. // NDEBUG, but it's far better to just use the underlying allocator
  142. // instead when no checking is desired.
  143. // There is some evidence that this can confuse Purify.
  144. // This adaptor can only be applied to raw allocators
  145.  
  146. template <class _Alloc>
  147. class __debug_alloc : public _Alloc {
  148. public:
  149.   typedef _Alloc __allocator_type;
  150.   typedef typename _Alloc::value_type value_type;
  151. private:
  152.   struct __alloc_header {
  153.     size_t __magic: 16;
  154.     size_t __type_size:16;
  155.     _STLP_UINT32_T _M_size;
  156.   }; // that is 8 bytes for sure
  157.   // Sunpro CC has bug on enums, so extra_before/after set explicitly
  158.   enum { __pad=8, __magic=0xdeba, __deleted_magic = 0xdebd,
  159.      __shred_byte= _STLP_SHRED_BYTE
  160.   };
  161.  
  162.   enum { __extra_before = 16, __extra_after = 8 };
  163.   // Size of space used to store size.  Note
  164.   // that this must be large enough to preserve
  165.   // alignment.
  166.   static size_t _STLP_CALL __extra_before_chunk() {
  167.     return (long)__extra_before/sizeof(value_type)+
  168.       (size_t)((long)__extra_before%sizeof(value_type)>0);
  169.   }
  170.   static size_t _STLP_CALL __extra_after_chunk() {
  171.     return (long)__extra_after/sizeof(value_type)+
  172.       (size_t)((long)__extra_after%sizeof(value_type)>0);
  173.   }
  174. public:
  175. # if defined (_STLP_MEMBER_TEMPLATE_CLASSES) && defined (_STLP_USE_RAW_SGI_ALLOCATORS)
  176.   template <class _Tp1> struct rebind {
  177.     typedef __allocator< _Tp1, __debug_alloc<_Alloc> > other;
  178.   };
  179. # endif
  180.   __debug_alloc() {}
  181.   ~__debug_alloc() {}
  182.   static void * _STLP_CALL allocate(size_t);
  183.   static void _STLP_CALL deallocate(void *, size_t);
  184. };
  185.  
  186.  
  187. // Default node allocator.
  188. // With a reasonable compiler, this should be roughly as fast as the
  189. // original STL class-specific allocators, but with less fragmentation.
  190. // Default_alloc_template parameters are experimental and MAY
  191. // DISAPPEAR in the future.  Clients should just use alloc for now.
  192. //
  193. // Important implementation properties:
  194. // 1. If the client request an object of size > _MAX_BYTES, the resulting
  195. //    object will be obtained directly from malloc.
  196. // 2. In all other cases, we allocate an object of size exactly
  197. //    _S_round_up(requested_size).  Thus the client has enough size
  198. //    information that we can return the object to the proper free list
  199. //    without permanently losing part of the object.
  200. //
  201.  
  202. // The first template parameter specifies whether more than one thread
  203. // may use this allocator.  It is safe to allocate an object from
  204. // one instance of a default_alloc and deallocate it with another
  205. // one.  This effectively transfers its ownership to the second one.
  206. // This may have undesirable effects on reference locality.
  207. // The second parameter is unreferenced and serves only to allow the
  208. // creation of multiple default_alloc instances.
  209.  
  210. # if defined(__OS400__)
  211. enum {_ALIGN = 16, _ALIGN_SHIFT=4, _MAX_BYTES = 256};
  212. #  define  _STLP_NFREELISTS 16
  213. # else
  214. enum {_ALIGN = 8, _ALIGN_SHIFT=3, _MAX_BYTES = 128};
  215. #  define  _STLP_NFREELISTS 16
  216. # endif /* __OS400__ */
  217.  
  218. class _STLP_CLASS_DECLSPEC _Node_alloc_obj {
  219. public:
  220.     _Node_alloc_obj * _M_free_list_link;
  221. };
  222.  
  223. template <bool __threads, int __inst>
  224. class __node_alloc {
  225.   _STLP_PRIVATE:
  226.   static inline size_t _STLP_CALL _S_round_up(size_t __bytes) { return (((__bytes) + (size_t)_ALIGN-1) & ~((size_t)_ALIGN - 1)); }
  227.   typedef _Node_alloc_obj _Obj;
  228. private:
  229.   // Returns an object of size __n, and optionally adds to size __n free list.
  230.   static void*  _STLP_CALL _S_refill(size_t __n);
  231.   // Allocates a chunk for nobjs of size size.  nobjs may be reduced
  232.   // if it is inconvenient to allocate the requested number.
  233.   static char*  _STLP_CALL _S_chunk_alloc(size_t __p_size, int& __nobjs);
  234.   // Chunk allocation state.
  235.   static _Node_alloc_obj * _STLP_VOLATILE _S_free_list[_STLP_NFREELISTS]; 
  236.   static char* _S_start_free;
  237.   static char* _S_end_free;
  238.   static size_t _S_heap_size;
  239.   static void * _STLP_CALL _M_allocate(size_t __n);
  240.   /* __p may not be 0 */
  241.   static void _STLP_CALL _M_deallocate(void *__p, size_t __n);
  242. public:
  243.   // this one is needed for proper simple_alloc wrapping
  244.   typedef char value_type;
  245. # if defined (_STLP_MEMBER_TEMPLATE_CLASSES) && defined (_STLP_USE_RAW_SGI_ALLOCATORS)
  246.   template <class _Tp1> struct rebind {
  247.     typedef __allocator<_Tp1, __node_alloc<__threads, __inst> > other;
  248.   };
  249. # endif
  250.   /* __n must be > 0      */
  251.   static void * _STLP_CALL allocate(size_t __n) { return (__n > (size_t)_MAX_BYTES) ?  __stl_new(__n) : _M_allocate(__n); }
  252.   /* __p may not be 0 */
  253.   static void _STLP_CALL deallocate(void *__p, size_t __n) { if (__n > (size_t)_MAX_BYTES) __stl_delete(__p); else _M_deallocate(__p, __n); }
  254. };
  255.  
  256. # if defined (_STLP_USE_TEMPLATE_EXPORT)
  257. _STLP_EXPORT_TEMPLATE_CLASS __malloc_alloc<0>;
  258. _STLP_EXPORT_TEMPLATE_CLASS __node_alloc<_STLP_NODE_ALLOCATOR_THREADS, 0>;
  259. # endif /* _STLP_USE_TEMPLATE_EXPORT */
  260. typedef __node_alloc<_STLP_NODE_ALLOCATOR_THREADS, 0> _Node_alloc;
  261. # if defined (_STLP_USE_TEMPLATE_EXPORT)
  262. _STLP_EXPORT_TEMPLATE_CLASS __debug_alloc<_Node_alloc>;
  263. _STLP_EXPORT_TEMPLATE_CLASS __debug_alloc<__new_alloc>;
  264. _STLP_EXPORT_TEMPLATE_CLASS __debug_alloc<__malloc_alloc<0> >;
  265. # endif
  266.  
  267. # if defined (_STLP_USE_PERTHREAD_ALLOC)
  268.  
  269. _STLP_END_NAMESPACE
  270. // include additional header here
  271. # include <stl/_pthread_alloc.h>
  272. _STLP_BEGIN_NAMESPACE
  273.  
  274. #  if defined ( _STLP_DEBUG_ALLOC )
  275. typedef __debug_alloc<__pthread_alloc> __sgi_alloc;
  276. #  else
  277. typedef __pthread_alloc __sgi_alloc;
  278. #  endif /* _STLP_DEBUG_ALLOC */
  279.  
  280. typedef __pthread_alloc __single_client_alloc;
  281. typedef __pthread_alloc __multithreaded_alloc;
  282.  
  283. # else
  284.  
  285. # if defined ( _STLP_USE_NEWALLOC )
  286.  
  287. #  if defined ( _STLP_DEBUG_ALLOC )
  288. typedef __debug_alloc<__new_alloc> __sgi_alloc;
  289. #  else
  290. typedef __new_alloc __sgi_alloc;
  291. #  endif /* _STLP_DEBUG_ALLOC */
  292.  
  293. typedef __new_alloc __single_client_alloc;
  294. typedef __new_alloc __multithreaded_alloc;
  295.  
  296. #  elif defined (_STLP_USE_MALLOC)
  297.  
  298. #   if defined ( _STLP_DEBUG_ALLOC )
  299. typedef __debug_alloc<__malloc_alloc<0> > __sgi_alloc;
  300. #   else
  301. typedef __malloc_alloc<0> __sgi_alloc;
  302. #   endif /* _STLP_DEBUG_ALLOC */
  303.  
  304. typedef __malloc_alloc<0> __single_client_alloc;
  305. typedef __malloc_alloc<0> __multithreaded_alloc;
  306.  
  307. # else
  308.  
  309. #   if defined ( _STLP_DEBUG_ALLOC )
  310. typedef __debug_alloc<_Node_alloc> __sgi_alloc;
  311. #   else
  312. typedef _Node_alloc __sgi_alloc;
  313. #   endif
  314.  
  315. typedef __node_alloc<false, 0> __single_client_alloc;
  316. typedef __node_alloc<true, 0>  __multithreaded_alloc;
  317.  
  318. #  endif /* _STLP_USE_NEWALLOC */
  319. # endif /* PTHREAD_ALLOC */
  320.  
  321. // This implements allocators as specified in the C++ standard.  
  322. //
  323. // Note that standard-conforming allocators use many language features
  324. // that are not yet widely implemented.  In particular, they rely on
  325. // member templates, partial specialization, partial ordering of function
  326. // templates, the typename keyword, and the use of the template keyword
  327. // to refer to a template member of a dependent type.
  328.  
  329. template <class _Tp>
  330. class allocator {
  331. public:
  332.  
  333.   typedef _Tp        value_type;
  334.   typedef value_type *       pointer;
  335.   typedef const _Tp* const_pointer;
  336.   typedef _Tp&       reference;
  337.   typedef const _Tp& const_reference;
  338.   typedef size_t     size_type;
  339.   typedef ptrdiff_t  difference_type;
  340. # if defined (_STLP_MEMBER_TEMPLATE_CLASSES)
  341.   template <class _Tp1> struct rebind {
  342.     typedef allocator<_Tp1> other;
  343.   };
  344. # endif
  345.   allocator() _STLP_NOTHROW {}
  346.  # if defined (_STLP_MEMBER_TEMPLATES)
  347.   template <class _Tp1> allocator(const allocator<_Tp1>&) _STLP_NOTHROW {}
  348.  # endif    
  349.   allocator(const allocator<_Tp>&) _STLP_NOTHROW {}
  350.   ~allocator() _STLP_NOTHROW {}
  351.   pointer address(reference __x) { return &__x; }
  352.   const_pointer address(const_reference __x) const { return &__x; }
  353.   // __n is permitted to be 0.  The C++ standard says nothing about what the return value is when __n == 0.
  354.   _Tp* allocate(size_type __n, const void* = 0) const { 
  355.     return __n != 0 ? __REINTERPRET_CAST(value_type*,__sgi_alloc::allocate(__n * sizeof(value_type))) : 0;
  356.   }
  357.   // __p is permitted to be a null pointer, only if n==0.
  358.   void deallocate(pointer __p, size_type __n) const {
  359.     _STLP_ASSERT( (__p == 0) == (__n == 0) )
  360.       if (__p != 0) __sgi_alloc::deallocate((void*)__p, __n * sizeof(value_type));
  361.   }
  362.   // backwards compatibility
  363.   void deallocate(pointer __p) const {  if (__p != 0) __sgi_alloc::deallocate((void*)__p, sizeof(value_type)); }
  364.   size_type max_size() const _STLP_NOTHROW  { return size_t(-1) / sizeof(value_type); }
  365.   void construct(pointer __p, const _Tp& __val) const { _STLP_STD::_Construct(__p, __val); }
  366.   void destroy(pointer __p) const { _STLP_STD::_Destroy(__p); }
  367. # if defined(__MRC__)||defined(__SC__)
  368.   template <class _T2> bool operator==(const allocator<_T2>&) const  { return true; }
  369.   template <class _T2> bool operator!=(const allocator<_T2>&) const { return false; }
  370. # endif
  371. };
  372.  
  373. _STLP_TEMPLATE_NULL
  374. class _STLP_CLASS_DECLSPEC allocator<void> {
  375. public:
  376.   typedef size_t      size_type;
  377.   typedef ptrdiff_t   difference_type;
  378.   typedef void*       pointer;
  379.   typedef const void* const_pointer;
  380. # if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
  381.   typedef void        value_type;
  382. # endif
  383. # if defined (_STLP_MEMBER_TEMPLATE_CLASSES)
  384.   template <class _Tp1> struct rebind {
  385.     typedef allocator<_Tp1> other;
  386.   };
  387. # endif
  388. # if defined(__MRC__)||defined(__SC__)        //*ty 03/24/2001 - MPW compilers get confused on these operator definitions
  389.   template <class _T2> bool operator==(const allocator<_T2>&) const  { return true; }
  390.   template <class _T2> bool operator!=(const allocator<_T2>&) const { return false; }
  391. # endif
  392. };
  393.  
  394. #if !(defined(__MRC__)||defined(__SC__))        //*ty 03/24/2001 - MPW compilers get confused on these operator definitions
  395. template <class _T1, class _T2> inline bool  _STLP_CALL operator==(const allocator<_T1>&, const allocator<_T2>&)  { return true; }
  396. template <class _T1, class _T2> inline bool  _STLP_CALL operator!=(const allocator<_T1>&, const allocator<_T2>&) { return false; }
  397. #endif
  398.  
  399. # if defined (_STLP_USE_TEMPLATE_EXPORT)
  400. _STLP_EXPORT_TEMPLATE_CLASS allocator<char>;
  401. #  if defined (_STLP_HAS_WCHAR_T)
  402. _STLP_EXPORT_TEMPLATE_CLASS allocator<wchar_t>;
  403. #  endif
  404. # endif /* _STLP_USE_TEMPLATE_EXPORT */
  405.  
  406. // Another allocator adaptor: _Alloc_traits.  This serves two
  407. // purposes.  First, make it possible to write containers that can use
  408. // either SGI-style allocators or standard-conforming allocator.
  409.  
  410. // The fully general version.
  411. template <class _Tp, class _Allocator>
  412. struct _Alloc_traits
  413. {
  414.   typedef _Allocator _Orig;
  415. # if defined (_STLP_MEMBER_TEMPLATE_CLASSES) 
  416.   typedef typename _Allocator::_STLP_TEMPLATE rebind<_Tp> _Rebind_type;
  417.   typedef typename _Rebind_type::other  allocator_type;
  418.   static allocator_type create_allocator(const _Orig& __a) { return allocator_type(__a); }
  419. # else
  420.   // this is not actually true, used only to pass this type through
  421.   // to dynamic overload selection in _STLP_alloc_proxy methods
  422.   typedef _Allocator allocator_type;
  423. # endif
  424. };
  425.  
  426. #ifndef _STLP_FORCE_ALLOCATORS
  427. #define _STLP_FORCE_ALLOCATORS(a,y) 
  428. #endif
  429.  
  430. #if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && ! defined (_STLP_MEMBER_TEMPLATE_CLASSES)
  431. // The version for the default allocator, for rare occasion when we have partial spec w/o member template classes
  432. template <class _Tp, class _Tp1>
  433. struct _Alloc_traits<_Tp, allocator<_Tp1> > {
  434.   typedef allocator<_Tp1> _Orig;
  435.   typedef allocator<_Tp> allocator_type;
  436.   static allocator_type create_allocator(const allocator<_Tp1 >& __a) { return allocator_type(__a); }
  437. };
  438. #endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
  439.  
  440. /* macro to convert the allocator for initialization
  441.  * not using MEMBER_TEMPLATE_CLASSES as it should work given template constructor  */
  442. #if defined (_STLP_MEMBER_TEMPLATES) || ! defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
  443. /* if _STLP_NO_TEMPLATE_CONVERSIONS is set, the member template constructor is
  444.  * not used implicitly to convert allocator parameter, so let us do it explicitly */
  445. # if defined (_STLP_MEMBER_TEMPLATE_CLASSES) && defined (_STLP_NO_TEMPLATE_CONVERSIONS)
  446. #  define _STLP_CONVERT_ALLOCATOR(__a, _Tp) __stl_alloc_create(__a,(_Tp*)0)
  447. # else
  448. #  define _STLP_CONVERT_ALLOCATOR(__a, _Tp) __a
  449. # endif
  450. /* else convert, but only if partial specialization works, since else
  451.  * Container::allocator_type won't be different */
  452. #else 
  453. #  define _STLP_CONVERT_ALLOCATOR(__a, _Tp) __stl_alloc_create(__a,(_Tp*)0)
  454. #endif
  455.  
  456. # if defined (_STLP_MEMBER_TEMPLATE_CLASSES) 
  457. template <class _Tp, class _Alloc>
  458. inline _STLP_TYPENAME_ON_RETURN_TYPE _Alloc_traits<_Tp, _Alloc>::allocator_type  _STLP_CALL
  459. __stl_alloc_create(const _Alloc& __a, const _Tp*) {
  460.   typedef typename _Alloc::_STLP_TEMPLATE rebind<_Tp>::other _Rebound_type;
  461.   return _Rebound_type(__a);
  462. }
  463. #else
  464. // If custom allocators are being used without member template classes support :
  465. // user (on purpose) is forced to define rebind/get operations !!!
  466. template <class _Tp1, class _Tp2>
  467. inline allocator<_Tp2>& _STLP_CALL
  468. __stl_alloc_rebind(allocator<_Tp1>& __a, const _Tp2*) {  return (allocator<_Tp2>&)(__a); }
  469. template <class _Tp1, class _Tp2>
  470. inline allocator<_Tp2> _STLP_CALL
  471. __stl_alloc_create(const allocator<_Tp1>&, const _Tp2*) { return allocator<_Tp2>(); }
  472. #endif /* _STLP_MEMBER_TEMPLATE_CLASSES */
  473.  
  474. # ifdef _STLP_USE_RAW_SGI_ALLOCATORS
  475. // move obsolete stuff out of the way
  476. # include <stl/_alloc_old.h>
  477. # endif
  478.  
  479. // inheritance is being used for EBO optimization
  480. template <class _Value, class _Tp, class _MaybeReboundAlloc>
  481. class _STLP_alloc_proxy : public _MaybeReboundAlloc {
  482. private:
  483.   typedef _MaybeReboundAlloc _Base;
  484.   typedef _STLP_alloc_proxy<_Value, _Tp, _MaybeReboundAlloc> _Self;
  485. public:
  486.   _Value _M_data;
  487.   inline _STLP_alloc_proxy(const _MaybeReboundAlloc& __a, _Value __p) : _MaybeReboundAlloc(__a), _M_data(__p) {}
  488.  
  489. # if 0
  490.   inline _STLP_alloc_proxy(const _Self& __x) : _MaybeReboundAlloc(__x), _M_data(__x._M_data) {} 
  491.   // construction/destruction
  492.   inline _Self& operator = (const _Self& __x) { 
  493.     *(_MaybeReboundAlloc*)this = *(_MaybeReboundAlloc*)__x;
  494.     _M_data = __x._M_data; return *this; 
  495.   } 
  496.   inline _Self& operator = (const _Base& __x) { ((_Base&)*this) = __x; return *this; } 
  497. # endif
  498.   // Unified interface to perform allocate()/deallocate() with limited
  499.   // language support
  500. #if ! defined (_STLP_MEMBER_TEMPLATE_CLASSES)
  501.   // else it is rebound already, and allocate() member is accessible
  502.   inline _Tp* allocate(size_t __n) { 
  503.     return __stl_alloc_rebind(__STATIC_CAST(_Base&,*this),(_Tp*)0).allocate(__n,0); 
  504.   }
  505.   inline void deallocate(_Tp* __p, size_t __n) { 
  506.     __stl_alloc_rebind(__STATIC_CAST(_Base&, *this),(_Tp*)0).deallocate(__p, __n); 
  507.   }
  508. #endif
  509. };
  510.  
  511. # if defined (_STLP_USE_TEMPLATE_EXPORT)
  512. _STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<char *,char,allocator<char> >;
  513. #  if defined (_STLP_HAS_WCHAR_T)
  514. _STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<wchar_t *,wchar_t,allocator<wchar_t> >;
  515. #  endif
  516. # endif /* _STLP_USE_TEMPLATE_EXPORT */
  517.  
  518. # undef _STLP_NODE_ALLOCATOR_THREADS
  519.  
  520. _STLP_END_NAMESPACE
  521.  
  522. # if defined (_STLP_EXPOSE_GLOBALS_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
  523. #  include <stl/_alloc.c>
  524. # endif
  525.  
  526. #endif /* _STLP_INTERNAL_ALLOC_H */
  527.  
  528. // Local Variables:
  529. // mode:C++
  530. // End:
  531.  
  532.