Boost logo

Boost :

From: Dean Michael Berris (mikhailberis_at_[hidden])
Date: 2007-09-23 09:29:52


Hi Tobias!

On 9/22/07, Tobias Schwinger <tschwinger_at_[hidden]> wrote:
> Dean Michael Berris wrote:
> >
> > Would there be a way for me to iterate through every element of 'ints'
> > and apply the function object instance to each element, and stop the
> > iteration only when function does not throw?
>
> No.
>

I thought so. That confirms my suspicion that there isn't an obvious
way of doing it. :-)

> > I know using exceptions for control flow is pretty frowned upon,
>
> ...and pretty inefficient, unless to terminate a deep recursion.
>
> But to answer you're question, you can of course wrap another function
> around yours that throws if it doesn't catch anything :-).
>

This makes sense, but a little too convoluted for my taste. It's one
of the options, and I don't know if there's even an alternative
that'll be easy to use aside from the above suggestion. Thanks for the
idea. ;)

> Reading the rest of your post, it seems you're basically looking for
> algorithms like these:
>
> visit_if(sequence_reference,runtime_predicate,action)
> visit_where_first(sequence_reference,runtime_predicate,action)
>

Close, but not quite...

I'm thinking of a fusion function (if there isn't one already) which
short-circuits (or returns) when it finds the first element of a
sequece_reference, for which there is a runtime_predicate that holds
true -- and then perform an action.

If 'visit_where_first' does the above, then I think something like
that will be useful -- particulary in my case ;-).

I'm looking through the Boost Trunk version of Fusion, but I don't see
it in the documentation. I'm willing to try my hand at implementing
the above, though it would be great if someone's already done it. :-D

> Correct?

Sure sounds like it. :)

>
>
> Regards,
> Tobias
>

Thanks Tobias!

-- 
Dean Michael C. Berris
Software Engineer, Friendster, Inc.
[http://cplusplus-soup.blogspot.com/]
[mikhailberis_at_[hidden]]
[+63 928 7291459]
[+1 408 4049523]

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