
shunsuke wrote:
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
I'm interested! This ought to be part of fusion :-) Regards, -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net