Boost logo

Boost :

From: shunsuke (pstade.mb_at_[hidden])
Date: 2007-09-24 04:00:45


Dean Michael Berris wrote:
> struct equals_2 {
> template <typename T>
> T operator() (T element) const {
> if (element == 2) return element;
> };
> };
>
> typedef fusion::tuple<int, int, int> point_type;
> point_type point(1, 2, 3);
> assert(fusion::is_homogenous<point_type>::value == true);
> assert(fusion::find_first_if<equals_2>(point) == 2); // only works if
> 'point' is a homogeneous container

FWIW, a few weeks ago, I had a radical idea
about an iterator which runs through a tuple/fusion.

rectangle r; triangle t; circle c;
boost::tuple<rectangle*, triangle*, circle*> tup(&r, &t, &c);
BOOST_FOREACH (shape *s, oven::hetero<shape *>(tup)) {
     s->draw();
}

If interested, here is the implementation: http://tinyurl.com/2gojyw

Regards,

-- 
Shunsuke Sogame

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