This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[v3] _M_get_Tp_allocator by ref to mainline / 4_1
- From: Paolo Carlini <pcarlini at suse dot de>
- To: "'gcc-patches at gcc dot gnu dot org'" <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 15 Dec 2005 12:29:44 +0100
- Subject: [v3] _M_get_Tp_allocator by ref to mainline / 4_1
Hi,
I'm finishing testing on x86-linux this patchlet, coming from v7, and
going to both mainline and 4_1-branch.
The reason why we have to do that now, for 4_1 too, is that these
functions are new in 4_1 and if we get the return type wrong we cannot
change it anymore (the mismatch would bite when linking translation
units using different versions, compiled at low optimization levels (->
i.e., _M_get_Tp_allocator not inlined).
Paolo.
//////////////////
2005-12-15 Paolo Carlini <pcarlini@suse.de>
* include/bits/stl_vector.h (vector<>::_M_get_Tp_allocator): Change
to return by ref and add non const version.
* include/bits/stl_deque.h (deque<>::_M_get_Tp_allocator): Likewise.
Index: include/bits/stl_vector.h
===================================================================
--- include/bits/stl_vector.h (revision 108564)
+++ include/bits/stl_vector.h (working copy)
@@ -91,7 +91,11 @@
public:
typedef _Alloc allocator_type;
- _Tp_alloc_type
+ _Tp_alloc_type&
+ _M_get_Tp_allocator()
+ { return *static_cast<_Tp_alloc_type*>(&this->_M_impl); }
+
+ const _Tp_alloc_type&
_M_get_Tp_allocator() const
{ return *static_cast<const _Tp_alloc_type*>(&this->_M_impl); }
Index: include/bits/stl_deque.h
===================================================================
--- include/bits/stl_deque.h (revision 108564)
+++ include/bits/stl_deque.h (working copy)
@@ -395,7 +395,11 @@
{ }
};
- _Tp_alloc_type
+ _Tp_alloc_type&
+ _M_get_Tp_allocator()
+ { return *static_cast<_Tp_alloc_type*>(&this->_M_impl); }
+
+ const _Tp_alloc_type&
_M_get_Tp_allocator() const
{ return *static_cast<const _Tp_alloc_type*>(&this->_M_impl); }