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 #ifndef __SGI_STL_INTERNAL_CONSTRUCT_H
00032 #define __SGI_STL_INTERNAL_CONSTRUCT_H
00033
00034 #ifndef UNDER_CE
00035 #include <new.h>
00036 #else
00037 #include <wce_defs.h>
00038 #endif
00039
00040 __STL_BEGIN_NAMESPACE
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 template <class _T1, class _T2>
00051 inline void _Construct(_T1* __p, const _T2& __value) {
00052 new ((void*) __p) _T1(__value);
00053 }
00054
00055 template <class _T1>
00056 inline void _Construct(_T1* __p) {
00057 new ((void*) __p) _T1();
00058 }
00059
00060 template <class _Tp>
00061 inline void _Destroy(_Tp* __pointer) {
00062 __pointer->~_Tp();
00063 }
00064
00065 template <class _ForwardIterator>
00066 void
00067 __destroy_aux(_ForwardIterator __first, _ForwardIterator __last, __false_type)
00068 {
00069 for ( ; __first != __last; ++__first)
00070 destroy(&*__first);
00071 }
00072
00073 template <class _ForwardIterator>
00074 inline void __destroy_aux(_ForwardIterator, _ForwardIterator, __true_type) {}
00075
00076 template <class _ForwardIterator, class _Tp>
00077 inline void
00078 __destroy(_ForwardIterator __first, _ForwardIterator __last, _Tp*)
00079 {
00080 typedef typename __type_traits<_Tp>::has_trivial_destructor
00081 _Trivial_destructor;
00082 __destroy_aux(__first, __last, _Trivial_destructor());
00083 }
00084
00085 template <class _ForwardIterator>
00086 inline void _Destroy(_ForwardIterator __first, _ForwardIterator __last) {
00087 __destroy(__first, __last, __VALUE_TYPE(__first));
00088 }
00089
00090 inline void _Destroy(char*, char*) {}
00091 inline void _Destroy(int*, int*) {}
00092 inline void _Destroy(long*, long*) {}
00093 inline void _Destroy(float*, float*) {}
00094 inline void _Destroy(double*, double*) {}
00095 #ifdef __STL_HAS_WCHAR_T
00096 inline void _Destroy(wchar_t*, wchar_t*) {}
00097 #endif
00098
00099
00100
00101
00102 template <class _T1, class _T2>
00103 inline void construct(_T1* __p, const _T2& __value) {
00104 _Construct(__p, __value);
00105 }
00106
00107 template <class _T1>
00108 inline void construct(_T1* __p) {
00109 _Construct(__p);
00110 }
00111
00112 template <class _Tp>
00113 inline void destroy(_Tp* __pointer) {
00114 _Destroy(__pointer);
00115 }
00116
00117 template <class _ForwardIterator>
00118 inline void destroy(_ForwardIterator __first, _ForwardIterator __last) {
00119 _Destroy(__first, __last);
00120 }
00121
00122 __STL_END_NAMESPACE
00123
00124 #endif
00125
00126
00127
00128