1/* 2 * 3 * Copyright (c) 1994 4 * Hewlett-Packard Company 5 * 6 * Permission to use, copy, modify, distribute and sell this software 7 * and its documentation for any purpose is hereby granted without fee, 8 * provided that the above copyright notice appear in all copies and 9 * that both that copyright notice and this permission notice appear 10 * in supporting documentation. Hewlett-Packard Company makes no 11 * representations about the suitability of this software for any 12 * purpose. It is provided "as is" without express or implied warranty. 13 * 14 * 15 * Copyright (c) 1996,1997 16 * Silicon Graphics Computer Systems, Inc. 17 * 18 * Permission to use, copy, modify, distribute and sell this software 19 * and its documentation for any purpose is hereby granted without fee, 20 * provided that the above copyright notice appear in all copies and 21 * that both that copyright notice and this permission notice appear 22 * in supporting documentation. Silicon Graphics makes no 23 * representations about the suitability of this software for any 24 * purpose. It is provided "as is" without express or implied warranty. 25 */ 26 27/* NOTE: This is an internal header file, included by other STL headers. 28 * You should not attempt to use it directly. 29 */ 30 31#ifndef __SGI_STL_INTERNAL_CONSTRUCT_H 32#define __SGI_STL_INTERNAL_CONSTRUCT_H 33 34#include <new.h> 35 36__STL_BEGIN_NAMESPACE 37 38// construct and destroy. These functions are not part of the C++ standard, 39// and are provided for backward compatibility with the HP STL. 40 41template <class _Tp> 42inline void destroy(_Tp* __pointer) { 43 __pointer->~_Tp(); 44} 45 46template <class _T1, class _T2> 47inline void construct(_T1* __p, const _T2& __value) { 48 new (__p) _T1(__value); 49} 50 51template <class _T1> 52inline void construct(_T1* __p) { 53 new (__p) _T1(); 54} 55 56template <class _ForwardIterator> 57inline void 58__destroy_aux(_ForwardIterator __first, _ForwardIterator __last, __false_type) 59{ 60 for ( ; __first != __last; ++__first) 61 destroy(&*__first); 62} 63 64template <class _ForwardIterator> 65inline void __destroy_aux(_ForwardIterator, _ForwardIterator, __true_type) {} 66 67template <class _ForwardIterator, class _Tp> 68inline void 69__destroy(_ForwardIterator __first, _ForwardIterator __last, _Tp*) 70{ 71 typedef typename __type_traits<_Tp>::has_trivial_destructor 72 _Trivial_destructor; 73 __destroy_aux(__first, __last, _Trivial_destructor()); 74} 75 76template <class _ForwardIterator> 77inline void destroy(_ForwardIterator __first, _ForwardIterator __last) { 78 __destroy(__first, __last, __VALUE_TYPE(__first)); 79} 80 81inline void destroy(char*, char*) {} 82inline void destroy(wchar_t*, wchar_t*) {} 83 84__STL_END_NAMESPACE 85 86#endif /* __SGI_STL_INTERNAL_CONSTRUCT_H */ 87 88// Local Variables: 89// mode:C++ 90// End: 91