Boost logo

Boost Users :

From: Vyacheslav Kononenko (groups_at_[hidden])
Date: 2005-06-14 21:36:04


--- Aleksey Gurtovoy <agurtovoy_at_[hidden]> wrote:

> Vyacheslav Kononenko writes:
> > I could not come with usable name for such thing
> but it could be
> > usable anyway. So it is like find_if but applies
> a function to an
> > sequence and return first non void type that
> function returned. So
> > implementation would be trivial:
> >
> > template< typename Sequence, typename Func >
> > struct find_type : fold< Sequence, void_, if_<
> > is_void_< _1 >, Func< _2 >, _1 > {};
>
> Or, which is likely to be more efficient,
>
> template< typename Seq, typename F > struct
> find_type
> {
> typedef typename find_if<
> transform_view<Seq,F>
> , is_not_void_<_1>
> >::type iter_;
>
> typedef typename eval_if<
> is_same< typename iter_::base,
> typename end<Seq>::type >
> , void_
> , deref<iter_>
> >::type type;
> };

Correct my if I am wrong but your will invoke F on
every element when mine will not.
 
> > If it can be implemented by current set of
> algorithms
> > please point me out.
>
> Doesn't your sketch above employ an algorithm from
> the current set
> ('fold')? In any case, at the moment this feels too
> specialized to me
> to be considered for inclusion in the library. At
> the very least, it
> needs a name ;).

There is another topic about mpl for_each and I think
my algo would be usable there. But for the name it is
an author work to make names isn't it?
 
> --
> Aleksey Gurtovoy
> MetaCommunications Engineering
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
>
http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net