ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

_construct.h
Go to the documentation of this file.
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_INTERNAL_CSTRING)
00034 #  include <stl/_cstring.h>
00035 #endif
00036 
00037 #ifndef _STLP_INTERNAL_NEW
00038 #  include <stl/_new.h>
00039 #endif
00040 
00041 #ifndef _STLP_INTERNAL_ITERATOR_BASE_H
00042 #  include <stl/_iterator_base.h>
00043 #endif
00044 
00045 #ifndef _STLP_TYPE_TRAITS_H
00046 #  include <stl/type_traits.h>
00047 #endif
00048 
00049 #if !defined (_STLP_MOVE_CONSTRUCT_FWK_H) && !defined (_STLP_NO_MOVE_SEMANTIC)
00050 #  include <stl/_move_construct_fwk.h>
00051 #endif
00052 
00053 _STLP_BEGIN_NAMESPACE
00054 
00055 template <class _Tp>
00056 inline void __destroy_aux(_Tp* __pointer, const __false_type& /*_Trivial_destructor*/)
00057 { __pointer->~_Tp(); }
00058 
00059 template <class _Tp>
00060 inline void __destroy_aux(_Tp*, const __true_type& /*_Trivial_destructor*/) {}
00061 
00062 template <class _Tp>
00063 inline void _Destroy(_Tp* __pointer) {
00064   typedef typename __type_traits<_Tp>::has_trivial_destructor _Trivial_destructor;
00065   __destroy_aux(__pointer, _Trivial_destructor());
00066 #if defined (_STLP_DEBUG_UNINITIALIZED)
00067   memset(__REINTERPRET_CAST(char*, __pointer), _STLP_SHRED_BYTE, sizeof(_Tp));
00068 #endif
00069 }
00070 
00071 template <class _Tp>
00072 inline void _Destroy_Moved(_Tp* __pointer) {
00073 #if !defined (_STLP_NO_MOVE_SEMANTIC)
00074   typedef typename __move_traits<_Tp>::complete _Trivial_destructor;
00075   __destroy_aux(__pointer, _Trivial_destructor());
00076 #  if defined (_STLP_DEBUG_UNINITIALIZED)
00077   memset((char*)__pointer, _STLP_SHRED_BYTE, sizeof(_Tp));
00078 #  endif
00079 #else
00080   _Destroy(__pointer);
00081 #endif
00082 }
00083 
00084 #if defined (new)
00085 #  define _STLP_NEW_REDEFINE new
00086 #  undef new
00087 #endif
00088 
00089 template <class _T1>
00090 inline void _Construct_aux (_T1* __p, const __false_type&) {
00091   new(__p) _T1();
00092 }
00093 
00094 template <class _T1>
00095 inline void _Construct_aux (_T1* __p, const __true_type&) {
00096 #if defined (_STLP_DEF_CONST_PLCT_NEW_BUG)
00097   *__p = _T1(0);
00098 #else
00099   // We use binary copying for POD types since it results
00100   // in a considerably better code at least on MSVC.
00101   *__p = _T1();
00102 #endif /* _STLP_DEF_CONST_PLCT_NEW_BUG */
00103 }
00104 
00105 template <class _T1>
00106 inline void _Construct(_T1* __p) {
00107 #if defined (_STLP_DEBUG_UNINITIALIZED)
00108   memset((char*)__p, _STLP_SHRED_BYTE, sizeof(_T1));
00109 #endif
00110 #if defined (_STLP_DEF_CONST_PLCT_NEW_BUG)
00111   _Construct_aux (__p, _HasDefaultZeroValue(__p)._Answer());
00112 #else
00113   _Construct_aux (__p, _Is_POD(__p)._Answer());
00114 #endif /* _STLP_DEF_CONST_PLCT_NEW_BUG */
00115 }
00116 
00117 template <class _Tp>
00118 inline void _Copy_Construct_aux(_Tp* __p, const _Tp& __val, const __false_type&) {
00119   new(__p) _Tp(__val);
00120 }
00121 
00122 template <class _Tp>
00123 inline void _Copy_Construct_aux(_Tp* __p, const _Tp& __val, const __true_type&) {
00124   // We use binary copying for POD types since it results
00125   // in a considerably better code at least on MSVC.
00126   *__p = __val;
00127 }
00128 
00129 template <class _Tp>
00130 inline void _Copy_Construct(_Tp* __p, const _Tp& __val) {
00131 #if defined (_STLP_DEBUG_UNINITIALIZED)
00132   memset((char*)__p, _STLP_SHRED_BYTE, sizeof(_Tp));
00133 #endif
00134   _Copy_Construct_aux(__p, __val, _Is_POD(__p)._Answer());
00135 }
00136 
00137 template <class _T1, class _T2>
00138 inline void _Param_Construct_aux(_T1* __p, const _T2& __val, const __false_type&) {
00139   new(__p) _T1(__val);
00140 }
00141 
00142 template <class _T1, class _T2>
00143 inline void _Param_Construct_aux(_T1* __p, const _T2& __val, const __true_type&) {
00144   // We use binary copying for POD types since it results
00145   // in a considerably better code at least on MSVC.
00146   *__p = _T1(__val);
00147 }
00148 
00149 template <class _T1, class _T2>
00150 inline void _Param_Construct(_T1* __p, const _T2& __val) {
00151 #if defined (_STLP_DEBUG_UNINITIALIZED)
00152   memset((char*)__p, _STLP_SHRED_BYTE, sizeof(_T1));
00153 #endif
00154   _Param_Construct_aux(__p, __val, _Is_POD(__p)._Answer());
00155 }
00156 
00157 template <class _T1, class _T2>
00158 inline void _Move_Construct_Aux(_T1* __p, _T2& __val, const __false_type& /*_IsPOD*/) {
00159 #if !defined (_STLP_NO_MOVE_SEMANTIC)
00160   new(__p) _T1(_STLP_PRIV _AsMoveSource(__val));
00161 #else
00162   _Param_Construct(__p, __val);
00163 #endif
00164 }
00165 
00166 template <class _T1, class _T2>
00167 inline void _Move_Construct_Aux(_T1* __p, _T2& __val, const __true_type& /*_IsPOD*/) {
00168   // We use binary copying for POD types since it results
00169   // in a considerably better code at least on MSVC.
00170   *__p = _T1(__val);
00171 }
00172 
00173 template <class _T1, class _T2>
00174 inline void _Move_Construct(_T1* __p, _T2& __val) {
00175 #if defined (_STLP_DEBUG_UNINITIALIZED)
00176   memset((char*)__p, _STLP_SHRED_BYTE, sizeof(_T1));
00177 #endif
00178   _Move_Construct_Aux(__p, __val, _Is_POD(__p)._Answer());
00179 }
00180 
00181 #if defined(_STLP_NEW_REDEFINE)
00182 #  if defined (DEBUG_NEW)
00183 #    define new DEBUG_NEW
00184 #  endif
00185 #  undef _STLP_NEW_REDEFINE
00186 #endif
00187 
00188 template <class _ForwardIterator, class _Tp>
00189 _STLP_INLINE_LOOP void
00190 __destroy_range_aux(_ForwardIterator __first, _ForwardIterator __last, _Tp*, const __false_type& /*_Trivial_destructor*/) {
00191   for ( ; __first != __last; ++__first) {
00192     __destroy_aux(&(*__first), __false_type());
00193 #if defined (_STLP_DEBUG_UNINITIALIZED)
00194     memset((char*)&(*__first), _STLP_SHRED_BYTE, sizeof(_Tp));
00195 #endif
00196   }
00197 }
00198 
00199 template <class _ForwardIterator, class _Tp>
00200 #if defined (_STLP_DEBUG_UNINITIALIZED)
00201 _STLP_INLINE_LOOP void
00202 __destroy_range_aux(_ForwardIterator __first, _ForwardIterator __last, _Tp*, const __true_type& /*_Trivial_destructor*/) {
00203   for ( ; __first != __last; ++__first)
00204     memset((char*)&(*__first), _STLP_SHRED_BYTE, sizeof(_Tp));
00205 }
00206 #else
00207 inline void
00208 __destroy_range_aux(_ForwardIterator, _ForwardIterator, _Tp*, const __true_type& /*_Trivial_destructor*/) {}
00209 #endif
00210 
00211 template <class _ForwardIterator, class _Tp>
00212 inline void
00213 __destroy_range(_ForwardIterator __first, _ForwardIterator __last, _Tp *__ptr) {
00214   typedef typename __type_traits<_Tp>::has_trivial_destructor _Trivial_destructor;
00215   __destroy_range_aux(__first, __last, __ptr, _Trivial_destructor());
00216 }
00217 
00218 template <class _ForwardIterator>
00219 inline void _Destroy_Range(_ForwardIterator __first, _ForwardIterator __last) {
00220   __destroy_range(__first, __last, _STLP_VALUE_TYPE(__first, _ForwardIterator));
00221 }
00222 
00223 inline void _Destroy_Range(char*, char*) {}
00224 #if defined (_STLP_HAS_WCHAR_T) // dwa 8/15/97
00225 inline void _Destroy_Range(wchar_t*, wchar_t*) {}
00226 inline void _Destroy_Range(const wchar_t*, const wchar_t*) {}
00227 #endif
00228 
00229 #if !defined (_STLP_NO_MOVE_SEMANTIC)
00230 template <class _ForwardIterator, class _Tp>
00231 inline void
00232 __destroy_mv_srcs(_ForwardIterator __first, _ForwardIterator __last, _Tp *__ptr) {
00233   typedef typename __move_traits<_Tp>::complete _CompleteMove;
00234   __destroy_range_aux(__first, __last, __ptr, _CompleteMove());
00235 }
00236 #endif
00237 
00238 template <class _ForwardIterator>
00239 inline void _Destroy_Moved_Range(_ForwardIterator __first, _ForwardIterator __last)
00240 #if !defined (_STLP_NO_MOVE_SEMANTIC)
00241 { __destroy_mv_srcs(__first, __last, _STLP_VALUE_TYPE(__first, _ForwardIterator)); }
00242 #else
00243 { _Destroy_Range(__first, __last); }
00244 #endif
00245 
00246 #if defined (_STLP_DEF_CONST_DEF_PARAM_BUG)
00247 // Those adaptors are here to fix common compiler bug regarding builtins:
00248 // expressions like int k = int() should initialize k to 0
00249 template <class _Tp>
00250 inline _Tp __default_constructed_aux(_Tp*, const __false_type&) {
00251   return _Tp();
00252 }
00253 template <class _Tp>
00254 inline _Tp __default_constructed_aux(_Tp*, const __true_type&) {
00255   return _Tp(0);
00256 }
00257 
00258 template <class _Tp>
00259 inline _Tp __default_constructed(_Tp* __p) {
00260   return __default_constructed_aux(__p, _HasDefaultZeroValue(__p)._Answer());
00261 }
00262 
00263 #  define _STLP_DEFAULT_CONSTRUCTED(_TTp) __default_constructed((_TTp*)0)
00264 #else
00265 #  define _STLP_DEFAULT_CONSTRUCTED(_TTp) _TTp()
00266 #endif /* _STLP_DEF_CONST_DEF_PARAM_BUG */
00267 
00268 
00269 #if !defined (_STLP_NO_ANACHRONISMS)
00270 // --------------------------------------------------
00271 // Old names from the HP STL.
00272 
00273 template <class _T1, class _T2>
00274 inline void construct(_T1* __p, const _T2& __val) {_Param_Construct(__p, __val); }
00275 template <class _T1>
00276 inline void construct(_T1* __p) { _STLP_STD::_Construct(__p); }
00277 template <class _Tp>
00278 inline void destroy(_Tp* __pointer) {  _STLP_STD::_Destroy(__pointer); }
00279 template <class _ForwardIterator>
00280 inline void destroy(_ForwardIterator __first, _ForwardIterator __last) { _STLP_STD::_Destroy_Range(__first, __last); }
00281 #endif /* _STLP_NO_ANACHRONISMS */
00282 
00283 _STLP_END_NAMESPACE
00284 
00285 #endif /* _STLP_INTERNAL_CONSTRUCT_H */
00286 
00287 // Local Variables:
00288 // mode:C++
00289 // End:

Generated on Sun May 27 2012 04:28:51 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.