diff options
Diffstat (limited to 'contrib/libstdc++/include/bits/stl_construct.h')
-rw-r--r-- | contrib/libstdc++/include/bits/stl_construct.h | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/contrib/libstdc++/include/bits/stl_construct.h b/contrib/libstdc++/include/bits/stl_construct.h index afb3387..0a03fb7 100644 --- a/contrib/libstdc++/include/bits/stl_construct.h +++ b/contrib/libstdc++/include/bits/stl_construct.h @@ -1,6 +1,6 @@ // nonstandard construct and destroy functions -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -61,11 +61,11 @@ #ifndef _STL_CONSTRUCT_H #define _STL_CONSTRUCT_H 1 -#include <bits/type_traits.h> +#include <bits/cpp_type_traits.h> #include <new> -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + /** * @if maint * Constructs an object in existing memory by invoking an allocated @@ -117,7 +117,10 @@ namespace std inline void __destroy_aux(_ForwardIterator __first, _ForwardIterator __last, __false_type) - { for ( ; __first != __last; ++__first) std::_Destroy(&*__first); } + { + for (; __first != __last; ++__first) + std::_Destroy(&*__first); + } /** * @if maint @@ -146,12 +149,40 @@ namespace std { typedef typename iterator_traits<_ForwardIterator>::value_type _Value_type; - typedef typename __type_traits<_Value_type>::has_trivial_destructor - _Has_trivial_destructor; + typedef typename std::__is_scalar<_Value_type>::__type + _Has_trivial_destructor; std::__destroy_aux(__first, __last, _Has_trivial_destructor()); } -} // namespace std + + /** + * @if maint + * Destroy a range of objects using the supplied allocator. For + * nondefault allocators we do not optimize away invocation of + * destroy() even if _Tp has a trivial destructor. + * @endif + */ + + template <typename _Tp> class allocator; + + template<typename _ForwardIterator, typename _Allocator> + void + _Destroy(_ForwardIterator __first, _ForwardIterator __last, + _Allocator __alloc) + { + for (; __first != __last; ++__first) + __alloc.destroy(&*__first); + } + + template<typename _ForwardIterator, typename _Tp> + inline void + _Destroy(_ForwardIterator __first, _ForwardIterator __last, + allocator<_Tp>) + { + _Destroy(__first, __last); + } + +_GLIBCXX_END_NAMESPACE #endif /* _STL_CONSTRUCT_H */ |