deque: unneccessary copy constructor in _M_push_front_aux
Christoph Schlenker
Christoph.Schlenker@schlund.de
Fri Feb 7 10:23:00 GMT 2003
Thanks - I oversaw this sort of self-referencing...
Maybe the function should just be
template <class _Tp, class _Alloc>
void
deque<_Tp,_Alloc>::_M_push_front_aux(const value_type __t)
without the '&'... -- optimizer kills that anyway..
\Christoph
On Fri, 2003-02-07 at 10:37, Gabriel Dos Reis wrote:
> 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
--
Christoph Schlenker
Schlund + Partner AG
Erbprinzenstr. 4-12 Tel.0721/91374-388
76133 Karlsruhe Fax.0721/91374-212
http://www.schlund.de Christoph.Schlenker@schlund.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 524 bytes
Desc: This is a digitally signed message part
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20030207/72f00599/attachment.sig>
More information about the Libstdc++
mailing list