diff options
author | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-06-17 20:36:42 +0000 |
---|---|---|
committer | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-06-17 20:36:42 +0000 |
commit | 41129c36f0b331121039451621518ab9a9ef1347 (patch) | |
tree | 9d672c64476f379d076c01024a112af142202b6d /libstdc++-v3/python | |
parent | 2049d5c4fc064b1050b11ca055adac40e157cd42 (diff) | |
download | gcc-41129c36f0b331121039451621518ab9a9ef1347.tar.gz |
C++11 allocator support for std::list.
PR libstdc++/55409
* include/bits/list.tcc (_List_base::_M_clear()): Use allocator traits.
(list::list(const list&)): Use allocator propagation trait. Use
_M_assign_dispatch to copy elements.
* include/bits/stl_list.h (_List_node): Use __aligned_membuf in C++11.
(_List_node::_M_valptr()): Add accessor for stored value.
(_List_iterator, _List_const_iterator, _List_base): Use _M_valptr().
(_List_base, list): Use allocator traits.
(_List_base::_M_get_Tp_allocator, _List_base::get_allocator): Remove.
(_List_base::_M_move_nodes): New function.
(_List_base(_List_base&&)): Use _M_move_nodes.
(_List_base(_List_base&&, _Node_alloc_type&&)): New constructor.
(list::_M_create_node, list::_M_erase, list::max_size): Use allocator
traits.
(list(size_type)): Add allocator parameter.
(list(const list&)): Use allocator propagation trait.
(list(const list&, const allocator_type&)): New constructor.
(list(list&&, const allocator_type&)): Likewise.
(list::operator=(list&&), list::swap(list&)): Use allocator
propagation traits.
(list::_M_move_assign): New functions.
* include/debug/list: Add allocator-extended constructors.
* include/profile/list: Likewise.
* python/libstdcxx/v6/printers.py (get_value_from_list_node): New
function to get value from _List_node.
(StdListPrinter): Use get_value_from_list_node.
* testsuite/23_containers/list/allocator/copy.cc: New.
* testsuite/23_containers/list/allocator/copy_assign.cc: New.
* testsuite/23_containers/list/allocator/minimal.cc: New.
* testsuite/23_containers/list/allocator/move.cc: New.
* testsuite/23_containers/list/allocator/move_assign.cc: New.
* testsuite/23_containers/list/allocator/noexcept.cc: New.
* testsuite/23_containers/list/allocator/swap.cc: New.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc:
Adjust dg-prune-output line number.
* testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc:
Likewise.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc:
Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@224580 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/python')
-rw-r--r-- | libstdc++-v3/python/libstdcxx/v6/printers.py | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index 2b6e4096ae4..2d167863ad3 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -128,6 +128,22 @@ class UniquePointerPrinter: return ('std::unique_ptr<%s> containing %s' % (str(v.type.target()), str(v))) +def get_value_from_list_node(node): + """Returns the value held in an _List_node<_Val>""" + try: + member = node.type.fields()[1].name + if member == '_M_data': + # C++03 implementation, node contains the value as a member + return node['_M_data'] + elif member == '_M_storage': + # C++11 implementation, node stores value in __aligned_membuf + p = node['_M_storage']['_M_storage'].address + p = p.cast(node.type.template_argument(0).pointer()) + return p.dereference() + except: + pass + raise ValueError("Unsupported implementation for %s" % str(node.type)) + class StdListPrinter: "Print a std::list" @@ -148,7 +164,8 @@ class StdListPrinter: self.base = elt['_M_next'] count = self.count self.count = self.count + 1 - return ('[%d]' % count, elt['_M_data']) + val = get_value_from_list_node(elt) + return ('[%d]' % count, val) def __init__(self, typename, val): self.typename = typename @@ -174,7 +191,8 @@ class StdListIteratorPrinter: def to_string(self): nodetype = find_type(self.val.type, '_Node') nodetype = nodetype.strip_typedefs().pointer() - return self.val['_M_node'].cast(nodetype).dereference()['_M_data'] + node = self.val['_M_node'].cast(nodetype).dereference() + return get_value_from_list_node(node) class StdSlistPrinter: "Print a __gnu_cxx::slist" @@ -440,7 +458,7 @@ def get_value_from_Rb_tree_node(node): # C++03 implementation, node contains the value as a member return node['_M_value_field'] elif member == '_M_storage': - # C++11 implementation, node stores value in __aligned_buffer + # C++11 implementation, node stores value in __aligned_membuf p = node['_M_storage']['_M_storage'].address p = p.cast(node.type.template_argument(0).pointer()) return p.dereference() |