Boost logo

Boost :

From: Michael Fawcett (michael.fawcett_at_[hidden])
Date: 2008-04-28 13:26:56


On Mon, Apr 28, 2008 at 11:10 AM, David Abrahams
<dave_at_[hidden]> wrote:
>
> One more thing to note about the case of terminating graph algorithms
> with exceptions: these algorithms have *lots* of hooks for each
> iteration of the process, each of which might need to terminate the
> algorithm
> (e.g. http://www.boost.org/doc/libs/1_35_0/libs/graph/doc/DFSVisitor.html),
> so that can add up to quite a few tests for each iteration of the inner
> loop, which can be avoided if EH is used.

Understood. I thought we were simply talking about the cost of an
exception vs the cost of *one more* hook (e.g. an at_goal() hook).
Most of the algorithms loop until some container is empty, or until
the search area is exhausted. This one extra hook would be in
addition to that check, e.g.

while (search_not_exhausted && visitor.at_goal(current) == false) { /*
call other hooks */ }

Their visitor can handle the details of storing another bool if they
need to be able to signal termination from any hook.

--Michael Fawcett


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