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