summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3/include/ext/memory
diff options
context:
space:
mode:
authoraustern <austern@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-28 16:37:20 +0000
committeraustern <austern@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-28 16:37:20 +0000
commite1d16db9f02de0b077724dcead586362cffa0e5e (patch)
tree1c1e052f56fe594ac2a2f7349bea7763b2fdca24 /libstdc++-v3/include/ext/memory
parent31a3877c6bbad48f75f5a8b6b4fe4e7eed77ab38 (diff)
downloadppe42-gcc-e1d16db9f02de0b077724dcead586362cffa0e5e.tar.gz
ppe42-gcc-e1d16db9f02de0b077724dcead586362cffa0e5e.zip
* include/bits/stl_construct.h (_Destroy): New three-argument
overload that takes an allocator argument. Another inline three-argument overload that takes std::allocator and dispatches to the two-argument version. * include/bits/stl_uninitialized.h (__uninitialized_fill_n_aux): Change return type to void to match uninitialized_fill_n. (__uninitialized_copy_a_): New function. Like uninitialized_copy except that it takes an allocator and uses it for construct and destroy. If the allocator is std::allocator, dispatches to uninitialized_copy. (__uninitialized_fill_a): Likewise. (__uninitialized_fill_n_a): Likewise. (__uninitialized_copy_copy): Give it an allocator argument. (__uninitialized_fill_copy): Likewise. (__uninitialized_copy_fill): Likewise. * include/bits/deque.tcc: Use new forms defined in stl_construct.h and stl_uninitialized.h. Replace use of single-argument _Construct and _Destroy with use of allocator's construct and destroy methods. * include/bits/list.tcc: Likewise. * include/bits/stl_deque.h: Likewise. * include/bits/stl_list.h: Likewise. * include/bits/stl_tree.h: Likewise. * include/bits/stl_vector.h: Likewise. * include/bits/vector.tcc: Likewise. * include/ext/hashtable.h: Use rebind so that allocator_type has correct type for a container's allocator. Replace use of single-argument _Construct and _Destroy with use of allocator's construct and destroy methods. * include/ext/memory (__uninitialized_copy_n_a): New function. Like uninitialized_copy_n except that it takes an extra parameter, an allocator, and uses it for construct and destroy operations. * include/ext/rope: Use new forms defined in stl_construct.h, stl_uninitialized.h, and ext/memory. Replace use of single-argument _Construct and _Destroy with allocator construct and destroy methods. * include/ext/ropeimpl.h: Likewise. * include/ext/slist.h: Likewise. * testsuite/testsuite_allocator.h (check_construct_destroy): New. * testsuite/testsuite_allocator.cc (check_construct_destroy): New. * testsuite/23_containers/deque/check_construct_destroy.cc: New. * testsuite/23_containers/list/check_construct_destroy.cc: New. * testsuite/23_containers/set/check_construct_destroy.cc: New. * testsuite/23_containers/vector/check_construct_destroy.cc: New. * testsuite/ext/hash_check_construct_destroy.cc: New. * testsuite/ext/slist_check_construct_destroy.cc: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@85265 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/ext/memory')
-rw-r--r--libstdc++-v3/include/ext/memory34
1 files changed, 34 insertions, 0 deletions
diff --git a/libstdc++-v3/include/ext/memory b/libstdc++-v3/include/ext/memory
index adb15ce2992..dc04657180d 100644
--- a/libstdc++-v3/include/ext/memory
+++ b/libstdc++-v3/include/ext/memory
@@ -128,6 +128,40 @@ namespace __gnu_cxx
{ return __uninitialized_copy_n(__first, __count, __result,
__iterator_category(__first)); }
+
+ // An alternative version of uninitialized_copy_n that constructs
+ // and destroys objects with a user-provided allocator.
+ template<typename _InputIter, typename _Size, typename _ForwardIter,
+ typename _Allocator>
+ pair<_InputIter, _ForwardIter>
+ __uninitialized_copy_n_a(_InputIter __first, _Size __count,
+ _ForwardIter __result,
+ _Allocator __alloc)
+ {
+ _ForwardIter __cur = __result;
+ try
+ {
+ for (; __count > 0 ; --__count, ++__first, ++__cur)
+ __alloc.construct(&*__cur, *__first);
+ return pair<_InputIter, _ForwardIter>(__first, __cur);
+ }
+ catch(...)
+ {
+ std::_Destroy(__result, __cur, __alloc);
+ __throw_exception_again;
+ }
+ }
+
+ template<typename _InputIter, typename _Size, typename _ForwardIter,
+ typename _Tp>
+ inline pair<_InputIter, _ForwardIter>
+ __uninitialized_copy_n_a(_InputIter __first, _Size __count,
+ _ForwardIter __result,
+ std::allocator<_Tp>)
+ {
+ return uninitialized_copy_n(__first, __count, __result);
+ }
+
/**
* This class provides similar behavior and semantics of the standard
* functions get_temporary_buffer() and return_temporary_buffer(), but
OpenPOWER on IntegriCloud