epoc32/include/tools/stlport/stl/_construct.h
branchSymbian3
changeset 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/tools/stlport/stl/_construct.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -0,0 +1,245 @@
     1.4 +/*
     1.5 + *
     1.6 + * Copyright (c) 1994
     1.7 + * Hewlett-Packard Company
     1.8 + *
     1.9 + * Copyright (c) 1996,1997
    1.10 + * Silicon Graphics Computer Systems, Inc.
    1.11 + *
    1.12 + * Copyright (c) 1997
    1.13 + * Moscow Center for SPARC Technology
    1.14 + *
    1.15 + * Copyright (c) 1999
    1.16 + * Boris Fomitchev
    1.17 + *
    1.18 + * This material is provided "as is", with absolutely no warranty expressed
    1.19 + * or implied. Any use is at your own risk.
    1.20 + *
    1.21 + * Permission to use or copy this software for any purpose is hereby granted
    1.22 + * without fee, provided the above notices are retained on all copies.
    1.23 + * Permission to modify the code and to distribute modified code is granted,
    1.24 + * provided the above notices are retained, and a notice that the code was
    1.25 + * modified is included with the above copyright notice.
    1.26 + *
    1.27 + */
    1.28 +
    1.29 +/* NOTE: This is an internal header file, included by other STL headers.
    1.30 + *   You should not attempt to use it directly.
    1.31 + */
    1.32 +
    1.33 +#ifndef _STLP_INTERNAL_CONSTRUCT_H
    1.34 +#define _STLP_INTERNAL_CONSTRUCT_H
    1.35 +
    1.36 +#if !defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_INTERNAL_CSTRING)
    1.37 +#  include <stl/_cstring.h>
    1.38 +#endif
    1.39 +
    1.40 +#ifndef _STLP_INTERNAL_NEW
    1.41 +#  include <stl/_new.h>
    1.42 +#endif
    1.43 +
    1.44 +#ifndef _STLP_INTERNAL_ITERATOR_BASE_H
    1.45 +#  include <stl/_iterator_base.h>
    1.46 +#endif
    1.47 +
    1.48 +#ifndef _STLP_MOVE_CONSTRUCT_FWK_H
    1.49 +#  include <stl/_move_construct_fwk.h>
    1.50 +#endif
    1.51 +
    1.52 +_STLP_BEGIN_NAMESPACE
    1.53 +
    1.54 +template <class _Tp>
    1.55 +inline void __destroy_aux(_Tp* __pointer, const __false_type& /*_Trivial_destructor*/)
    1.56 +{ __pointer->~_Tp(); }
    1.57 +
    1.58 +template <class _Tp>
    1.59 +inline void __destroy_aux(_Tp*, const __true_type& /*_Trivial_destructor*/) {}
    1.60 +
    1.61 +template <class _Tp>
    1.62 +inline void _Destroy(_Tp* __pointer) {
    1.63 +#if defined (_STLP_MSVC) && (_STLP_MSVC <= 1010)
    1.64 +  __pointer;
    1.65 +#endif
    1.66 +  typedef typename __type_traits<_Tp>::has_trivial_destructor _Trivial_destructor;
    1.67 +  __destroy_aux(__pointer, _Trivial_destructor());
    1.68 +#if defined (_STLP_DEBUG_UNINITIALIZED)
    1.69 +  memset(__REINTERPRET_CAST(char*, __pointer), _STLP_SHRED_BYTE, sizeof(_Tp));
    1.70 +#endif
    1.71 +}
    1.72 +
    1.73 +template <class _Tp>
    1.74 +inline void _Destroy_Moved(_Tp* __pointer) {
    1.75 +  typedef typename __move_traits<_Tp>::complete _Trivial_destructor;
    1.76 +  __destroy_aux(__pointer, _Trivial_destructor());
    1.77 +#if defined (_STLP_DEBUG_UNINITIALIZED)
    1.78 +  memset((char*)__pointer, _STLP_SHRED_BYTE, sizeof(_Tp));
    1.79 +#endif
    1.80 +}
    1.81 +
    1.82 +#if defined (new)
    1.83 +#  define _STLP_NEW_REDEFINE new
    1.84 +#  undef new
    1.85 +#endif
    1.86 +
    1.87 +#if defined (_STLP_DEF_CONST_PLCT_NEW_BUG)
    1.88 +template <class _T1>
    1.89 +inline void _Construct_aux (_T1* __p, const __false_type&) {
    1.90 +  _STLP_PLACEMENT_NEW (__p) _T1();
    1.91 +}
    1.92 +
    1.93 +template <class _T1>
    1.94 +inline void _Construct_aux (_T1* __p, const __true_type&) {
    1.95 +  _STLP_PLACEMENT_NEW (__p) _T1(0);
    1.96 +}
    1.97 +#endif /* _STLP_DEF_CONST_PLCT_NEW_BUG */
    1.98 +
    1.99 +template <class _T1>
   1.100 +inline void _Construct(_T1* __p) {
   1.101 +#if defined (_STLP_DEBUG_UNINITIALIZED)
   1.102 +  memset((char*)__p, _STLP_SHRED_BYTE, sizeof(_T1));
   1.103 +#endif
   1.104 +#if defined (_STLP_DEF_CONST_PLCT_NEW_BUG)
   1.105 +  _Construct_aux (__p, _HasDefaultZeroValue(__p)._Answer() );
   1.106 +#else
   1.107 +  _STLP_PLACEMENT_NEW (__p) _T1();
   1.108 +#endif /* _STLP_DEF_CONST_PLCT_NEW_BUG */
   1.109 +}
   1.110 +
   1.111 +template <class _Tp>
   1.112 +inline void _Copy_Construct(_Tp* __p, const _Tp& __val) {
   1.113 +#if defined (_STLP_DEBUG_UNINITIALIZED)
   1.114 +  memset((char*)__p, _STLP_SHRED_BYTE, sizeof(_Tp));
   1.115 +#endif
   1.116 +  _STLP_PLACEMENT_NEW (__p) _Tp(__val);
   1.117 +}
   1.118 +
   1.119 +template <class _T1, class _T2>
   1.120 +inline void _Param_Construct(_T1* __p, const _T2& __val) {
   1.121 +#if defined (_STLP_DEBUG_UNINITIALIZED)
   1.122 +  memset((char*)__p, _STLP_SHRED_BYTE, sizeof(_T1));
   1.123 +#endif
   1.124 +  _STLP_PLACEMENT_NEW (__p) _T1(__val);
   1.125 +}
   1.126 +
   1.127 +template <class _T1, class _T2>
   1.128 +inline void _Move_Construct_Aux(_T1* __p, _T2& __val, const __false_type& /*_IsPOD*/) {
   1.129 +  _STLP_PLACEMENT_NEW (__p) _T1(_STLP_PRIV _AsMoveSource(__val));
   1.130 +}
   1.131 +
   1.132 +template <class _T1, class _T2>
   1.133 +inline void _Move_Construct_Aux(_T1* __p, _T2& __val, const __true_type& /*_IsPOD*/) {
   1.134 +  _STLP_PLACEMENT_NEW (__p) _T1(__val);
   1.135 +}
   1.136 +
   1.137 +template <class _T1, class _T2>
   1.138 +inline void _Move_Construct(_T1* __p, _T2& __val) {
   1.139 +#if defined (_STLP_DEBUG_UNINITIALIZED)
   1.140 +  memset((char*)__p, _STLP_SHRED_BYTE, sizeof(_T1));
   1.141 +#endif
   1.142 +  _Move_Construct_Aux(__p, __val, _Is_POD(__p)._Answer());
   1.143 +}
   1.144 +
   1.145 +#if defined(_STLP_NEW_REDEFINE)
   1.146 +#  if defined (DEBUG_NEW)
   1.147 +#    define new DEBUG_NEW
   1.148 +#  endif
   1.149 +#  undef _STLP_NEW_REDEFINE
   1.150 +#endif
   1.151 +
   1.152 +template <class _ForwardIterator, class _Tp>
   1.153 +_STLP_INLINE_LOOP void
   1.154 +__destroy_range_aux(_ForwardIterator __first, _ForwardIterator __last, _Tp*, const __false_type& /*_Trivial_destructor*/) {
   1.155 +  for ( ; __first != __last; ++__first) {
   1.156 +    __destroy_aux(&(*__first), __false_type());
   1.157 +#if defined (_STLP_DEBUG_UNINITIALIZED)
   1.158 +    memset((char*)&(*__first), _STLP_SHRED_BYTE, sizeof(_Tp));
   1.159 +#endif
   1.160 +  }
   1.161 +}
   1.162 +
   1.163 +template <class _ForwardIterator, class _Tp>
   1.164 +#if defined (_STLP_DEBUG_UNINITIALIZED)
   1.165 +_STLP_INLINE_LOOP void
   1.166 +__destroy_range_aux(_ForwardIterator __first, _ForwardIterator __last, _Tp*, const __true_type& /*_Trivial_destructor*/) {
   1.167 +  for ( ; __first != __last; ++__first)
   1.168 +    memset((char*)&(*__first), _STLP_SHRED_BYTE, sizeof(_Tp));
   1.169 +}
   1.170 +#else
   1.171 +inline void
   1.172 +__destroy_range_aux(_ForwardIterator, _ForwardIterator, _Tp*, const __true_type& /*_Trivial_destructor*/) {}
   1.173 +#endif
   1.174 +
   1.175 +template <class _ForwardIterator, class _Tp>
   1.176 +inline void
   1.177 +__destroy_range(_ForwardIterator __first, _ForwardIterator __last, _Tp *__ptr) {
   1.178 +  typedef typename __type_traits<_Tp>::has_trivial_destructor _Trivial_destructor;
   1.179 +  __destroy_range_aux(__first, __last, __ptr, _Trivial_destructor());
   1.180 +}
   1.181 +
   1.182 +template <class _ForwardIterator>
   1.183 +inline void _Destroy_Range(_ForwardIterator __first, _ForwardIterator __last) {
   1.184 +  __destroy_range(__first, __last, _STLP_VALUE_TYPE(__first, _ForwardIterator));
   1.185 +}
   1.186 +
   1.187 +inline void _Destroy_Range(char*, char*) {}
   1.188 +#if defined (_STLP_HAS_WCHAR_T) // dwa 8/15/97
   1.189 +inline void _Destroy_Range(wchar_t*, wchar_t*) {}
   1.190 +inline void _Destroy_Range(const wchar_t*, const wchar_t*) {}
   1.191 +#endif
   1.192 +
   1.193 +template <class _ForwardIterator, class _Tp>
   1.194 +inline void
   1.195 +__destroy_mv_srcs(_ForwardIterator __first, _ForwardIterator __last, _Tp *__ptr) {
   1.196 +  typedef typename __move_traits<_Tp>::complete _CompleteMove;
   1.197 +  __destroy_range_aux(__first, __last, __ptr, _CompleteMove());
   1.198 +}
   1.199 +
   1.200 +template <class _ForwardIterator>
   1.201 +inline void _Destroy_Moved_Range(_ForwardIterator __first, _ForwardIterator __last) {
   1.202 +  __destroy_mv_srcs(__first, __last, _STLP_VALUE_TYPE(__first, _ForwardIterator));
   1.203 +}
   1.204 +
   1.205 +#if defined (_STLP_DEF_CONST_DEF_PARAM_BUG)
   1.206 +// Those adaptors are here to fix common compiler bug regarding builtins:
   1.207 +// expressions like int k = int() should initialize k to 0
   1.208 +template <class _Tp>
   1.209 +inline _Tp __default_constructed_aux(_Tp*, const __false_type&) {
   1.210 +  return _Tp();
   1.211 +}
   1.212 +template <class _Tp>
   1.213 +inline _Tp __default_constructed_aux(_Tp*, const __true_type&) {
   1.214 +  return _Tp(0);
   1.215 +}
   1.216 +
   1.217 +template <class _Tp>
   1.218 +inline _Tp __default_constructed(_Tp* __p) {
   1.219 +  return __default_constructed_aux(__p, _HasDefaultZeroValue(__p)._Answer());
   1.220 +}
   1.221 +
   1.222 +#  define _STLP_DEFAULT_CONSTRUCTED(_TTp) __default_constructed((_TTp*)0)
   1.223 +#else
   1.224 +#  define _STLP_DEFAULT_CONSTRUCTED(_TTp) _TTp()
   1.225 +#endif /* _STLP_DEF_CONST_DEF_PARAM_BUG */
   1.226 +
   1.227 +
   1.228 +#if !defined (_STLP_NO_ANACHRONISMS)
   1.229 +// --------------------------------------------------
   1.230 +// Old names from the HP STL.
   1.231 +
   1.232 +template <class _T1, class _T2>
   1.233 +inline void construct(_T1* __p, const _T2& __val) {_Param_Construct(__p, __val); }
   1.234 +template <class _T1>
   1.235 +inline void construct(_T1* __p) { _STLP_STD::_Construct(__p); }
   1.236 +template <class _Tp>
   1.237 +inline void destroy(_Tp* __pointer) {  _STLP_STD::_Destroy(__pointer); }
   1.238 +template <class _ForwardIterator>
   1.239 +inline void destroy(_ForwardIterator __first, _ForwardIterator __last) { _STLP_STD::_Destroy_Range(__first, __last); }
   1.240 +#endif /* _STLP_NO_ANACHRONISMS */
   1.241 +
   1.242 +_STLP_END_NAMESPACE
   1.243 +
   1.244 +#endif /* _STLP_INTERNAL_CONSTRUCT_H */
   1.245 +
   1.246 +// Local Variables:
   1.247 +// mode:C++
   1.248 +// End: