*: Revert comment/license change from yesterday for all except libsupc++/unwind-cxx.h.
[official-gcc.git] / libstdc++-v3 / include / bits / stl_construct.h
blob3a38c343d4fd150309339bdd7c00afa3f714707f
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 _CPP_BITS_STL_CONSTRUCT_H
32 #define _CPP_BITS_STL_CONSTRUCT_H 1
34 #include <new>
36 namespace std
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.
45 // Internal names
47 template <class _T1, class _T2>
48 inline void _Construct(_T1* __p, const _T2& __value) {
49 new ((void*) __p) _T1(__value);
52 template <class _T1>
53 inline void _Construct(_T1* __p) {
54 new ((void*) __p) _T1();
57 template <class _Tp>
58 inline void _Destroy(_Tp* __pointer) {
59 __pointer->~_Tp();
62 template <class _ForwardIterator>
63 void
64 __destroy_aux(_ForwardIterator __first, _ForwardIterator __last, __false_type)
66 for ( ; __first != __last; ++__first)
67 destroy(&*__first);
70 template <class _ForwardIterator>
71 inline void __destroy_aux(_ForwardIterator, _ForwardIterator, __true_type) {}
73 template <class _ForwardIterator, class _Tp>
74 inline void
75 __destroy(_ForwardIterator __first, _ForwardIterator __last, _Tp*)
77 typedef typename __type_traits<_Tp>::has_trivial_destructor
78 _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);
102 template <class _T1>
103 inline void construct(_T1* __p) {
104 _Construct(__p);
107 template <class _Tp>
108 inline void destroy(_Tp* __pointer) {
109 _Destroy(__pointer);
112 template <class _ForwardIterator>
113 inline void destroy(_ForwardIterator __first, _ForwardIterator __last) {
114 _Destroy(__first, __last);
117 } // namespace std
119 #endif /* _CPP_BITS_STL_CONSTRUCT_H */
121 // Local Variables:
122 // mode:C++
123 // End: