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 _CPP_BITS_STL_CONSTRUCT_H
32 #define _CPP_BITS_STL_CONSTRUCT_H 1
39 // construct and destroy. These functions are not part of the C++ standard,
40 // and are provided for backward compatibility with the HP STL. We also
41 // provide internal names _Construct and _Destroy that can be used within
42 // the library, so that standard-conforming pieces don't have to rely on
43 // non-standard extensions.
47 template <class _T1
, class _T2
>
48 inline void _Construct(_T1
* __p
, const _T2
& __value
) {
49 new ((void*) __p
) _T1(__value
);
53 inline void _Construct(_T1
* __p
) {
54 new ((void*) __p
) _T1();
58 inline void _Destroy(_Tp
* __pointer
) {
62 template <class _ForwardIterator
>
64 __destroy_aux(_ForwardIterator __first
, _ForwardIterator __last
, __false_type
)
66 for ( ; __first
!= __last
; ++__first
)
70 template <class _ForwardIterator
>
71 inline void __destroy_aux(_ForwardIterator
, _ForwardIterator
, __true_type
) {}
73 template <class _ForwardIterator
, class _Tp
>
75 __destroy(_ForwardIterator __first
, _ForwardIterator __last
, _Tp
*)
77 typedef typename __type_traits
<_Tp
>::has_trivial_destructor
79 __destroy_aux(__first
, __last
, _Trivial_destructor());
82 template <class _ForwardIterator
>
83 inline void _Destroy(_ForwardIterator __first
, _ForwardIterator __last
) {
84 __destroy(__first
, __last
, __value_type(__first
));
87 inline void _Destroy(char*, char*) {}
88 inline void _Destroy(int*, int*) {}
89 inline void _Destroy(long*, long*) {}
90 inline void _Destroy(float*, float*) {}
91 inline void _Destroy(double*, double*) {}
92 inline void _Destroy(wchar_t*, wchar_t*) {}
94 // --------------------------------------------------
95 // Old names from the HP STL.
97 template <class _T1
, class _T2
>
98 inline void construct(_T1
* __p
, const _T2
& __value
) {
99 _Construct(__p
, __value
);
103 inline void construct(_T1
* __p
) {
108 inline void destroy(_Tp
* __pointer
) {
112 template <class _ForwardIterator
>
113 inline void destroy(_ForwardIterator __first
, _ForwardIterator __last
) {
114 _Destroy(__first
, __last
);
119 #endif /* _CPP_BITS_STL_CONSTRUCT_H */