diff options
author | fdumont <fdumont@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-09-24 19:55:35 +0000 |
---|---|---|
committer | fdumont <fdumont@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-09-24 19:55:35 +0000 |
commit | 39e522ee9f918ad56054a68db20d0b212dc31fc7 (patch) | |
tree | 6ac18352bbabea764bd719c371cf8c3175164ef1 /libstdc++-v3/testsuite/23_containers/multimap/allocator/move_assign.cc | |
parent | 16d41ae2f416c1a236bafe0131601894d74824c7 (diff) | |
download | gcc-39e522ee9f918ad56054a68db20d0b212dc31fc7.tar.gz |
2014-09-24 François Dumont <fdumont@gcc.gnu.org>
PR libstdc++/29988
* include/bits/stl_tree.h (_Rb_tree_reuse_or_alloc_node<>): New.
(_Rb_tree_alloc_node<>): New.
(_Rb_tree<>::operator=(_Rb_tree<>&&)): New.
(_Rb_tree<>::_M_assign_unique): New.
(_Rb_tree<>::_M_assign_equal): New.
(_Rb_tree<>): Adapt to reuse allocated nodes as much as possible.
* include/bits/stl_map.h
(std::map<>::operator=(std::map<>&&)): Default implementation.
(std::map<>::operator=(initializer_list<>)): Adapt to use
_Rb_tree::_M_assign_unique.
* include/bits/stl_multimap.h
(std::multimap<>::operator=(std::multimap<>&&)): Default implementation.
(std::multimap<>::operator=(initializer_list<>)): Adapt to use
_Rb_tree::_M_assign_equal.
* include/bits/stl_set.h
(std::set<>::operator=(std::set<>&&)): Default implementation.
(std::set<>::operator=(initializer_list<>)): Adapt to use
_Rb_tree::_M_assign_unique.
* include/bits/stl_multiset.h
(std::multiset<>::operator=(std::multiset<>&&)): Default implementation.
(std::multiset<>::operator=(initializer_list<>)): Adapt to use
_Rb_tree::_M_assign_equal.
* testsuite/23_containers/map/allocator/copy_assign.cc (test03): New.
* testsuite/23_containers/map/allocator/init-list.cc: New.
* testsuite/23_containers/map/allocator/move_assign.cc (test03): New.
* testsuite/23_containers/multimap/allocator/copy_assign.cc
(test03): New.
* testsuite/23_containers/multimap/allocator/init-list.cc: New.
* testsuite/23_containers/multimap/allocator/move_assign.cc
(test03): New.
* testsuite/23_containers/multiset/allocator/copy_assign.cc
(test03): New.
* testsuite/23_containers/multiset/allocator/init-list.cc: New.
* testsuite/23_containers/multiset/allocator/move_assign.cc
(test03): New.
* testsuite/23_containers/set/allocator/copy_assign.cc (test03): New.
* testsuite/23_containers/set/allocator/init-list.cc: New.
* testsuite/23_containers/set/allocator/move_assign.cc (test03): New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@215568 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/23_containers/multimap/allocator/move_assign.cc')
-rw-r--r-- | libstdc++-v3/testsuite/23_containers/multimap/allocator/move_assign.cc | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/23_containers/multimap/allocator/move_assign.cc b/libstdc++-v3/testsuite/23_containers/multimap/allocator/move_assign.cc index 6b1386120ac..11b5e357531 100644 --- a/libstdc++-v3/testsuite/23_containers/multimap/allocator/move_assign.cc +++ b/libstdc++-v3/testsuite/23_containers/multimap/allocator/move_assign.cc @@ -61,9 +61,42 @@ void test02() VERIFY( it == v2.begin() ); } +void test03() +{ + bool test __attribute__((unused)) = true; + + using namespace __gnu_test; + + typedef propagating_allocator<std::pair<const int, int>, false, + tracker_allocator<std::pair<const int, int>>> + alloc_type; + typedef std::multimap<int, int, std::less<int>, alloc_type> test_type; + + tracker_allocator_counter::reset(); + + test_type v1(alloc_type(1)); + v1 = { { 1, 1 }, { 1, 1 } }; + + test_type v2(alloc_type(2)); + v2 = { { 2, 2 }, { 2, 2 } }; + + auto allocs = tracker_allocator_counter::get_allocation_count(); + auto constructs = tracker_allocator_counter::get_construct_count(); + + // Check no allocation on move assignment with non propagating allocators. + v1 = std::move(v2); + + VERIFY( 1 == v1.get_allocator().get_personality() ); + VERIFY( 2 == v2.get_allocator().get_personality() ); + + VERIFY( tracker_allocator_counter::get_allocation_count() == allocs ); + VERIFY( tracker_allocator_counter::get_construct_count() == constructs + 2 ); +} + int main() { test01(); test02(); + test03(); return 0; } |