diff options
Diffstat (limited to 'libstdc++-v3/include/bits')
-rw-r--r-- | libstdc++-v3/include/bits/allocator.h | 20 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_deque.h | 5 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_list.h | 9 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_tree.h | 5 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_vector.h | 5 |
5 files changed, 42 insertions, 2 deletions
diff --git a/libstdc++-v3/include/bits/allocator.h b/libstdc++-v3/include/bits/allocator.h index 18bfd5f60eb..3e8d94a26e1 100644 --- a/libstdc++-v3/include/bits/allocator.h +++ b/libstdc++-v3/include/bits/allocator.h @@ -1,6 +1,7 @@ // Allocators -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 +// 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 @@ -128,6 +129,23 @@ _GLIBCXX_BEGIN_NAMESPACE(std) // Undefine. #undef __glibcxx_base_allocator + // To implement Option 3 of DR 431. + template<typename _Alloc, bool = std::__is_empty<_Alloc>::__value> + struct __alloc_swap + { static void _S_do_it(_Alloc&, _Alloc&) { } }; + + template<typename _Alloc> + struct __alloc_swap<_Alloc, false> + { + static void + _S_do_it(_Alloc& __one, _Alloc& __two) + { + // Precondition: swappable allocators. + if (__one != __two) + swap(__one, __two); + } + }; + _GLIBCXX_END_NAMESPACE #endif diff --git a/libstdc++-v3/include/bits/stl_deque.h b/libstdc++-v3/include/bits/stl_deque.h index d9bbb007b06..8f3fc99f61e 100644 --- a/libstdc++-v3/include/bits/stl_deque.h +++ b/libstdc++-v3/include/bits/stl_deque.h @@ -1195,6 +1195,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish); std::swap(this->_M_impl._M_map, __x._M_impl._M_map); std::swap(this->_M_impl._M_map_size, __x._M_impl._M_map_size); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 431. Swapping containers with unequal allocators. + std::__alloc_swap<_Tp_alloc_type>::_S_do_it(_M_get_Tp_allocator(), + __x._M_get_Tp_allocator()); } /** diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h index 1761bf5c133..513833c71ef 100644 --- a/libstdc++-v3/include/bits/stl_list.h +++ b/libstdc++-v3/include/bits/stl_list.h @@ -888,7 +888,14 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) */ void swap(list& __x) - { _List_node_base::swap(this->_M_impl._M_node, __x._M_impl._M_node); } + { + _List_node_base::swap(this->_M_impl._M_node, __x._M_impl._M_node); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 431. Swapping containers with unequal allocators. + std::__alloc_swap<typename _Base::_Node_alloc_type>:: + _S_do_it(_M_get_Node_allocator(), __x._M_get_Node_allocator()); + } /** * Erases all the elements. Note that this function only erases diff --git a/libstdc++-v3/include/bits/stl_tree.h b/libstdc++-v3/include/bits/stl_tree.h index c2acf87e350..01a8bad81c9 100644 --- a/libstdc++-v3/include/bits/stl_tree.h +++ b/libstdc++-v3/include/bits/stl_tree.h @@ -912,6 +912,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) // No need to swap header's color as it does not change. std::swap(this->_M_impl._M_node_count, __t._M_impl._M_node_count); std::swap(this->_M_impl._M_key_compare, __t._M_impl._M_key_compare); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 431. Swapping containers with unequal allocators. + std::__alloc_swap<_Node_allocator>:: + _S_do_it(_M_get_Node_allocator(), __t._M_get_Node_allocator()); } template<typename _Key, typename _Val, typename _KeyOfValue, diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h index 43f69de450e..b4434fca863 100644 --- a/libstdc++-v3/include/bits/stl_vector.h +++ b/libstdc++-v3/include/bits/stl_vector.h @@ -731,6 +731,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish); std::swap(this->_M_impl._M_end_of_storage, __x._M_impl._M_end_of_storage); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 431. Swapping containers with unequal allocators. + std::__alloc_swap<_Tp_alloc_type>::_S_do_it(_M_get_Tp_allocator(), + __x._M_get_Tp_allocator()); } /** |