stl_construct.h

00001 /*
00002  *
00003  * Copyright (c) 1994
00004  * Hewlett-Packard Company
00005  *
00006  * Permission to use, copy, modify, distribute and sell this software
00007  * and its documentation for any purpose is hereby granted without fee,
00008  * provided that the above copyright notice appear in all copies and
00009  * that both that copyright notice and this permission notice appear
00010  * in supporting documentation.  Hewlett-Packard Company makes no
00011  * representations about the suitability of this software for any
00012  * purpose.  It is provided "as is" without express or implied warranty.
00013  *
00014  *
00015  * Copyright (c) 1996,1997
00016  * Silicon Graphics Computer Systems, Inc.
00017  *
00018  * Permission to use, copy, modify, distribute and sell this software
00019  * and its documentation for any purpose is hereby granted without fee,
00020  * provided that the above copyright notice appear in all copies and
00021  * that both that copyright notice and this permission notice appear
00022  * in supporting documentation.  Silicon Graphics makes no
00023  * representations about the suitability of this software for any
00024  * purpose.  It is provided "as is" without express or implied warranty.
00025  */
00026 
00027 /* NOTE: This is an internal header file, included by other STL headers.
00028  *   You should not attempt to use it directly.
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 // construct and destroy.  These functions are not part of the C++ standard,
00043 // and are provided for backward compatibility with the HP STL.  We also
00044 // provide internal names _Construct and _Destroy that can be used within
00045 // the library, so that standard-conforming pieces don't have to rely on
00046 // non-standard extensions.
00047 
00048 // Internal names
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 /* __STL_HAS_WCHAR_T */
00098 
00099 // --------------------------------------------------
00100 // Old names from the HP STL.
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 /* __SGI_STL_INTERNAL_CONSTRUCT_H */
00125 
00126 // Local Variables:
00127 // mode:C++
00128 // End:

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