Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4680 | right-hear | 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 _CPP_BITS_STL_CONSTRUCT_H |
||
32 | #define _CPP_BITS_STL_CONSTRUCT_H 1 |
||
33 | |||
34 | #include |
||
35 | |||
36 | namespace std |
||
37 | { |
||
38 | |||
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. |
||
44 | |||
45 | // Internal names |
||
46 | |||
47 | template |
||
48 | inline void _Construct(_T1* __p, const _T2& __value) { |
||
49 | new ((void*) __p) _T1(__value); |
||
50 | } |
||
51 | |||
52 | template |
||
53 | inline void _Construct(_T1* __p) { |
||
54 | new ((void*) __p) _T1(); |
||
55 | } |
||
56 | |||
57 | template |
||
58 | inline void _Destroy(_Tp* __pointer) { |
||
59 | __pointer->~_Tp(); |
||
60 | } |
||
61 | |||
62 | template |
||
63 | void |
||
64 | __destroy_aux(_ForwardIterator __first, _ForwardIterator __last, __false_type) |
||
65 | { |
||
66 | for ( ; __first != __last; ++__first) |
||
67 | destroy(&*__first); |
||
68 | } |
||
69 | |||
70 | template |
||
71 | inline void __destroy_aux(_ForwardIterator, _ForwardIterator, __true_type) {} |
||
72 | |||
73 | template |
||
74 | inline void |
||
75 | __destroy(_ForwardIterator __first, _ForwardIterator __last, _Tp*) |
||
76 | { |
||
77 | typedef typename __type_traits<_Tp>::has_trivial_destructor |
||
78 | _Trivial_destructor; |
||
79 | __destroy_aux(__first, __last, _Trivial_destructor()); |
||
80 | } |
||
81 | |||
82 | template |
||
83 | inline void _Destroy(_ForwardIterator __first, _ForwardIterator __last) { |
||
84 | __destroy(__first, __last, __value_type(__first)); |
||
85 | } |
||
86 | |||
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*) {} |
||
93 | |||
94 | // -------------------------------------------------- |
||
95 | // Old names from the HP STL. |
||
96 | |||
97 | template |
||
98 | inline void construct(_T1* __p, const _T2& __value) { |
||
99 | _Construct(__p, __value); |
||
100 | } |
||
101 | |||
102 | template |
||
103 | inline void construct(_T1* __p) { |
||
104 | _Construct(__p); |
||
105 | } |
||
106 | |||
107 | template |
||
108 | inline void destroy(_Tp* __pointer) { |
||
109 | _Destroy(__pointer); |
||
110 | } |
||
111 | |||
112 | template |
||
113 | inline void destroy(_ForwardIterator __first, _ForwardIterator __last) { |
||
114 | _Destroy(__first, __last); |
||
115 | } |
||
116 | |||
117 | } // namespace std |
||
118 | |||
119 | #endif /* _CPP_BITS_STL_CONSTRUCT_H */ |
||
120 | |||
121 | // Local Variables: |
||
122 | // mode:C++ |
||
123 | // End: |