
18 Jul
2006
18 Jul
'06
10:58 p.m.
Giving the following code: #include <boost/mpl/integral_c.hpp> namespace mpl = boost::mpl; template < unsigned U, int I = 1 > struct T : mpl::integral_c< unsigned, U > { BOOST_STATIC_CONST(int, N = I); }; and two vectors of type T of varying lengths: typedef mpl::vector < T<0>, T<1>, T<2> > t1; typedef mpl::vector < T<2, 2>, T<0, 0> > t2; How would you create a joint view of t1 and t2, sorted by increasing U values, where all elements of t1 and t2 that have the same U value have their N constants added together. In the example above, the resulting type t0 would be equivalent to: typedef mpl::vector < T<0, 1>, T<1, 1>, T<2, 3> > t0; Thanks, Eric.