_construct.h

00001 /*
00002  *
00003  * Copyright (c) 1994
00004  * Hewlett-Packard Company
00005  *
00006  * Copyright (c) 1996,1997
00007  * Silicon Graphics Computer Systems, Inc.
00008  *
00009  * Copyright (c) 1997
00010  * Moscow Center for SPARC Technology
00011  *
00012  * Copyright (c) 1999 
00013  * Boris Fomitchev
00014  *
00015  * This material is provided "as is", with absolutely no warranty expressed
00016  * or implied. Any use is at your own risk.
00017  *
00018  * Permission to use or copy this software for any purpose is hereby granted 
00019  * without fee, provided the above notices are retained on all copies.
00020  * Permission to modify the code and to distribute modified code is granted,
00021  * provided the above notices are retained, and a notice that the code was
00022  * modified is included with the above copyright notice.
00023  *
00024  */
00025 
00026 /* NOTE: This is an internal header file, included by other STL headers.
00027  *   You should not attempt to use it directly.
00028  */
00029 
00030 #ifndef _STLP_INTERNAL_CONSTRUCT_H
00031 #define _STLP_INTERNAL_CONSTRUCT_H
00032 
00033 # if defined (_STLP_DEBUG_UNINITIALIZED) && ! defined (_STLP_CSTRING)
00034 # include <cstring>
00035 # endif
00036 
00037 # ifndef _STLP_NEW_HEADER
00038 #  include <new>
00039 # endif
00040 
00041 
00042 #ifndef _STLP_INTERNAL_ITERATOR_BASE_H
00043 # include <stl/_iterator_base.h>
00044 #endif
00045 
00046 _STLP_BEGIN_NAMESPACE
00047 
00048 # ifdef _STLP_TRIVIAL_DESTRUCTOR_BUG
00049 template <class _Tp>
00050 inline void __destroy_aux(_Tp* __pointer, const __false_type&) { __pointer->~_Tp(); }
00051 template <class _Tp>
00052 inline void __destroy_aux(_Tp* __pointer, const __true_type&) {}
00053 # endif
00054 
00055 template <class _Tp>
00056 inline void _Destroy(_Tp* __pointer) {
00057 # if _MSC_VER >= 1010 && !defined (__SYMBIAN32__)
00058   __pointer;
00059 # endif // _MSC_VER >= 1000
00060 # ifdef _STLP_TRIVIAL_DESTRUCTOR_BUG
00061   typedef typename __type_traits<_Tp>::has_trivial_destructor _Trivial_destructor;
00062   __destroy_aux(__pointer, _Trivial_destructor());
00063 # else
00064 #  if ( defined (__BORLANDC__) && ( __BORLANDC__ < 0x500 ) )
00065     __pointer->_Tp::~_Tp();
00066 #  else
00067     __pointer->~_Tp();
00068 #  endif
00069 # endif
00070 # ifdef _STLP_DEBUG_UNINITIALIZED
00071         memset((char*)__pointer, _STLP_SHRED_BYTE, sizeof(_Tp));
00072 # endif
00073 }
00074 
00075 # if defined (new)
00076 #   define _STLP_NEW_REDEFINE new
00077 #   undef new
00078 # endif 
00079 
00080 template <class _T1, class _T2>
00081 inline void _Construct(_T1* __p, const _T2& __value) {
00082 # ifdef _STLP_DEBUG_UNINITIALIZED
00083         memset((char*)__p, _STLP_SHRED_BYTE, sizeof(_T1));
00084 # endif
00085     _STLP_PLACEMENT_NEW (__p) _T1(__value);
00086 }
00087 
00088 template <class _T1>
00089 inline void _Construct(_T1* __p) {
00090 # ifdef _STLP_DEBUG_UNINITIALIZED
00091   memset((char*)__p, _STLP_SHRED_BYTE, sizeof(_T1));
00092 # endif
00093   _STLP_PLACEMENT_NEW (__p) _T1();
00094 }
00095 
00096 # if defined(_STLP_NEW_REDEFINE)
00097 # ifdef DEBUG_NEW
00098 #  define new DEBUG_NEW
00099 # endif
00100 #  undef _STLP_NEW_REDEFINE
00101 # endif 
00102 
00103 template <class _ForwardIterator>
00104 _STLP_INLINE_LOOP void
00105 __destroy_aux(_ForwardIterator __first, _ForwardIterator __last, const __false_type&) {
00106   for ( ; __first != __last; ++__first)
00107     _Destroy(&*__first);
00108 }
00109 
00110 template <class _ForwardIterator> 
00111 inline void __destroy_aux(_ForwardIterator, _ForwardIterator, const __true_type&) {}
00112 
00113 template <class _ForwardIterator, class _Tp>
00114 inline void 
00115 __destroy(_ForwardIterator __first, _ForwardIterator __last, _Tp*) {
00116   typedef typename __type_traits<_Tp>::has_trivial_destructor _Trivial_destructor;
00117   __destroy_aux(__first, __last, _Trivial_destructor());
00118 }
00119 
00120 template <class _ForwardIterator>
00121 inline void _Destroy(_ForwardIterator __first, _ForwardIterator __last) {
00122   __destroy(__first, __last, _STLP_VALUE_TYPE(__first, _ForwardIterator));
00123 }
00124 
00125 inline void _Destroy(char*, char*) {}
00126 # ifdef _STLP_HAS_WCHAR_T // dwa 8/15/97
00127 inline void _Destroy(wchar_t*, wchar_t*) {}
00128 inline void _Destroy(const wchar_t*, const wchar_t*) {}
00129 # endif
00130 
00131 # ifndef _STLP_NO_ANACHRONISMS
00132 // --------------------------------------------------
00133 // Old names from the HP STL.
00134 
00135 template <class _T1, class _T2>
00136 inline void construct(_T1* __p, const _T2& __value) {_Construct(__p, __value); }
00137 template <class _T1>
00138 inline void construct(_T1* __p) { _Construct(__p); }
00139 template <class _Tp>
00140 inline void destroy(_Tp* __pointer) {  _Destroy(__pointer); }
00141 template <class _ForwardIterator>
00142 inline void destroy(_ForwardIterator __first, _ForwardIterator __last) { _Destroy(__first, __last); }
00143 # endif
00144 _STLP_END_NAMESPACE
00145 
00146 #endif /* _STLP_INTERNAL_CONSTRUCT_H */
00147 
00148 // Local Variables:
00149 // mode:C++
00150 // End:

Generated on Mon Jun 5 10:20:45 2006 for Intelligence.kdevelop by  doxygen 1.4.6