Boost logo

Boost :

From: JOAQUIN LOPEZ MU?Z (joaquin_at_[hidden])
Date: 2005-03-14 16:21:13


----- Mensaje original -----
De: Douglas Gregor <doug.gregor_at_[hidden]>
Fecha: Lunes, Marzo 14, 2005 9:29 pm
Asunto: Re: [boost] Re: boost/pending/mutable_queue missing clear()
        function

>
> On Mar 14, 2005, at 12:55 PM, David Abrahams wrote:
>
> > Douglas Gregor <doug.gregor_at_[hidden]> writes:
> >
> >> On Feb 11, 2005, at 5:39 PM, Lloyd J Lewins wrote:
> >>
> >>> I notice that mutable_queue is missing a clear() function,
> i.e. a low
> >>> overhead way of emptying the entire queue (without resorting to
> >>> repeated
> >>> pops). However, I think clear() can be implemented as follows:
> >>>
> >>> void clear() { clear(); }
> >>>
> >>> Which is efficient and (often) fast.
> >
> > Surely that one only runs until you blow the stack. Am I missing
> > something?
>
> No, but neither did I :) The correct code (in CVS of course) is:
>
> void clear() { c.clear(); }
>

A silly and totally OT std-riddle: would an optimizer be
allowed to rewrite

  void clear() { clear(); }

as if:

  void clear() {}

? If not, why not? (with observable behavior in mind)

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk