Install gcc-4.3.3-tdm-1-g++.tar.gz
[git/jnareb-git.git] / mingw / lib / gcc / mingw32 / 4.3.3 / include / c++ / bits / stl_construct.h
blob1c4324eb0e1f30a4f259e7ff3717a7fd680cf651
1 // nonstandard construct and destroy functions -*- C++ -*-
3 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
4 // Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 2, or (at your option)
10 // any later version.
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING. If not, write to the Free
19 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20 // USA.
22 // As a special exception, you may use this file as part of a free software
23 // library without restriction. Specifically, if other files instantiate
24 // templates or use macros or inline functions from this file, or you compile
25 // this file and link it with other files to produce an executable, this
26 // file does not by itself cause the resulting executable to be covered by
27 // the GNU General Public License. This exception does not however
28 // invalidate any other reasons why the executable file might be covered by
29 // the GNU General Public License.
33 * Copyright (c) 1994
34 * Hewlett-Packard Company
36 * Permission to use, copy, modify, distribute and sell this software
37 * and its documentation for any purpose is hereby granted without fee,
38 * provided that the above copyright notice appear in all copies and
39 * that both that copyright notice and this permission notice appear
40 * in supporting documentation. Hewlett-Packard Company makes no
41 * representations about the suitability of this software for any
42 * purpose. It is provided "as is" without express or implied warranty.
45 * Copyright (c) 1996,1997
46 * Silicon Graphics Computer Systems, Inc.
48 * Permission to use, copy, modify, distribute and sell this software
49 * and its documentation for any purpose is hereby granted without fee,
50 * provided that the above copyright notice appear in all copies and
51 * that both that copyright notice and this permission notice appear
52 * in supporting documentation. Silicon Graphics makes no
53 * representations about the suitability of this software for any
54 * purpose. It is provided "as is" without express or implied warranty.
57 /** @file stl_construct.h
58 * This is an internal header file, included by other library headers.
59 * You should not attempt to use it directly.
62 #ifndef _STL_CONSTRUCT_H
63 #define _STL_CONSTRUCT_H 1
65 #include <new>
67 _GLIBCXX_BEGIN_NAMESPACE(std)
69 /**
70 * Constructs an object in existing memory by invoking an allocated
71 * object's constructor with an initializer.
73 template<typename _T1, typename _T2>
74 inline void
75 _Construct(_T1* __p, const _T2& __value)
77 // _GLIBCXX_RESOLVE_LIB_DEFECTS
78 // 402. wrong new expression in [some_]allocator::construct
79 ::new(static_cast<void*>(__p)) _T1(__value);
82 /**
83 * Destroy the object pointed to by a pointer type.
85 template<typename _Tp>
86 inline void
87 _Destroy(_Tp* __pointer)
88 { __pointer->~_Tp(); }
90 /**
91 * Destroy a range of objects. If the value_type of the object has
92 * a trivial destructor, the compiler should optimize all of this
93 * away, otherwise the objects' destructors must be invoked.
95 template<typename _ForwardIterator>
96 inline void
97 _Destroy(_ForwardIterator __first, _ForwardIterator __last)
99 typedef typename iterator_traits<_ForwardIterator>::value_type
100 _Value_type;
101 if (!__has_trivial_destructor(_Value_type))
102 for (; __first != __last; ++__first)
103 std::_Destroy(&*__first);
107 * Destroy a range of objects using the supplied allocator. For
108 * nondefault allocators we do not optimize away invocation of
109 * destroy() even if _Tp has a trivial destructor.
112 template <typename _Tp> class allocator;
114 template<typename _ForwardIterator, typename _Allocator>
115 void
116 _Destroy(_ForwardIterator __first, _ForwardIterator __last,
117 _Allocator& __alloc)
119 for (; __first != __last; ++__first)
120 __alloc.destroy(&*__first);
123 template<typename _ForwardIterator, typename _Tp>
124 inline void
125 _Destroy(_ForwardIterator __first, _ForwardIterator __last,
126 allocator<_Tp>&)
128 _Destroy(__first, __last);
131 _GLIBCXX_END_NAMESPACE
133 #endif /* _STL_CONSTRUCT_H */