How do I iterate over a tuple
Posted
by
Caligo
on Stack Overflow
See other posts from Stack Overflow
or by Caligo
Published on 2010-12-26T02:42:39Z
Indexed on
2010/12/26
2:54 UTC
Read the original article
Hit count: 179
How can I iterate over a tuple starting from, say, index 1 to 2? The following doesn't work.
using boost::fusion::cons;
typedef cons<A, cons<B, cons<C, cons<D> > > > MyTuple;
MyTuple tuple_;
template <class T>
struct DoSomething{
DoSomething(T& t) : t_(&t){ }
template <class U>
void operator()(U u){
boost::fusion::at<mpl::int_<u> >(*t_);
}
T* t_;
};
boost::mpl::for_each< boost::mpl::range_c<int, 1, 3> >( DoSomething<MyTuple>(tuple_) );
© Stack Overflow or respective owner