This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: deque: unneccessary copy constructor in _M_push_front_aux
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Christoph Schlenker <Christoph dot Schlenker at schlund dot de>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: 07 Feb 2003 10:37:39 +0100
- Subject: Re: deque: unneccessary copy constructor in _M_push_front_aux
- Organization: Integrable Solutions
- References: <1044608682.1608.1384.camel@cschlenk.schlund.de>
Christoph Schlenker <Christoph.Schlenker@schlund.de> writes:
| Hi all,
|
| I'm a bit puzzeled about line 1 in the function _M_push_front_aux in
|
| template <class _Tp, class _Alloc>
| void
| deque<_Tp,_Alloc>::_M_push_front_aux(const value_type& __t)
| {
| 1 value_type __t_copy = __t; // *** who needs that copy? ***
| 2 _M_reserve_map_at_front();
| 3 *(_M_start._M_node - 1) = _M_allocate_node();
| 4 try {
| 5 _M_start._M_set_node(_M_start._M_node - 1);
| 6 _M_start._M_cur = _M_start._M_last - 1;
| 7 _Construct(_M_start._M_cur, __t_copy);
| 8 }
| 9 catch(...)
| 0 {
| 1 ++_M_start;
| 2 _M_deallocate_node(*(_M_start._M_node - 1));
| 3 __throw_exception_again;
| 4 }
| }
|
| Can anyone tell we there is a __t_copy needed? As far as I can see
How would you handle this
d.push_front(d.back())
?
-- Gaby