Boost logo

Boost :

From: Andrei Alexandrescu (andrewalex_at_[hidden])
Date: 2003-01-24 14:46:25


"Hugo Duncan" <hugoduncan_at_[hidden]> wrote in message
news:1105_1043370662_at_news.gmane.org...
> On Wed, 22 Jan 2003 16:25:40 -0800, "Andrei Alexandrescu"
<andrewalex_at_[hidden]> wrote:
> >
> > inline void do_my_function(string&, void_) {}
> >
> > template <class Lst>
> > inline void do_my_function(string& s, Lst lst)
> > {
> > my_function<front<Lst>::type>(s);
> > do_my_function(s, pop_front<Lst>::type());
> > }
> > ....
> > do_my_function(s, my_list());
> >
>
> This is interesting as it also gives run-time control of how much of the
list
> is iterated over.
>
> eg.
>
> template <class Lst>
> inline void do_my_function(string& s, Lst lst)
> {
> if (!my_function<front<Lst>::type>(s))
> do_my_function(s, pop_front<Lst>::type());
> }

To add compliment to healing, an additional advantage is that you don't even
need to get for_each to compile.

Andrei


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