docs/ikteam: Delete most files.
[haiku.git] / headers / cpp / stl_construct.h
blob761784d57da0df2339ba5bd8b672e450ce1a2108
1 /*
3 * Copyright (c) 1994
4 * Hewlett-Packard Company
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.
15 * Copyright (c) 1996,1997
16 * Silicon Graphics Computer Systems, Inc.
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.
27 /* NOTE: This is an internal header file, included by other STL headers.
28 * You should not attempt to use it directly.
31 #ifndef __SGI_STL_INTERNAL_CONSTRUCT_H
32 #define __SGI_STL_INTERNAL_CONSTRUCT_H
34 #include <new.h>
36 __STL_BEGIN_NAMESPACE
38 // construct and destroy. These functions are not part of the C++ standard,
39 // and are provided for backward compatibility with the HP STL.
41 template <class _Tp>
42 inline void destroy(_Tp* __pointer) {
43 __pointer->~_Tp();
46 template <class _T1, class _T2>
47 inline void construct(_T1* __p, const _T2& __value) {
48 new (__p) _T1(__value);
51 template <class _T1>
52 inline void construct(_T1* __p) {
53 new (__p) _T1();
56 template <class _ForwardIterator>
57 inline void
58 __destroy_aux(_ForwardIterator __first, _ForwardIterator __last, __false_type)
60 for ( ; __first != __last; ++__first)
61 destroy(&*__first);
64 template <class _ForwardIterator>
65 inline void __destroy_aux(_ForwardIterator, _ForwardIterator, __true_type) {}
67 template <class _ForwardIterator, class _Tp>
68 inline void
69 __destroy(_ForwardIterator __first, _ForwardIterator __last, _Tp*)
71 typedef typename __type_traits<_Tp>::has_trivial_destructor
72 _Trivial_destructor;
73 __destroy_aux(__first, __last, _Trivial_destructor());
76 template <class _ForwardIterator>
77 inline void destroy(_ForwardIterator __first, _ForwardIterator __last) {
78 __destroy(__first, __last, __VALUE_TYPE(__first));
81 inline void destroy(char*, char*) {}
82 inline void destroy(wchar_t*, wchar_t*) {}
84 __STL_END_NAMESPACE
86 #endif /* __SGI_STL_INTERNAL_CONSTRUCT_H */
88 // Local Variables:
89 // mode:C++
90 // End: