
On Thu, Jul 10, 2008 at 2:47 AM, Sergei Politov <spolitov@gmail.com> wrote:
Peng Yu <pengyu.ut <at> gmail.com> writes:
The following program uses virtual functions. Essentially I need to go
[skip]
}
Am I correctly understand that you are looking for something link this: =================================================== #include <iostream>
#include <boost/fusion/algorithm.hpp> #include <boost/fusion/container.hpp>
struct square { void show_me() const { std::cout << "square"; } };
struct circle { void show_me() const { std::cout << "circle"; } };
struct triangle { void show_me() const { std::cout << "triangle"; } };
template<class T, class End> void out_pair(const T &, const End &, const End &) {}
template<class T, class Begin, class End> void out_pair(const T & t, const Begin & begin, const End & end) { t.show_me(); std::cout << " vs. "; deref(begin).show_me(); std::cout << std::endl; out_pair(t, next(begin), end); }
template<class End> void out(const End &, const End &) {}
template<class Begin, class End> void out(const Begin & begin, const End & end) { out_pair(deref(begin), next(begin), end); out(next(begin), end); }
int main() { typedef boost::fusion::vector<square, circle, square, triangle> Vec; Vec v; out(begin(v), end(v)); } ===================================================
Best Regards, Sergei
Hi, You understood me correctly. But it seems the transform from my code to your code is a little complicated. Is there any more direct analog between boost::fusion and the runtime algorithm. In particular, how to directly use two iterations with the second iteration start with something like it + 1 in my original code? Thanks, Peng