[Home]CPPTM Answers - Exercise 7-3

BOOST WIKI | RecentChanges | Preferences | Page List | Links List

No diff available--this is the first major revision. (no other diffs)
 // (by Ariel Badichi)
 #include <boost/static_assert.hpp>
 #include <boost/mpl/vector_c.hpp>
 #include <boost/mpl/advance.hpp>
 #include <boost/mpl/begin.hpp>
 #include <boost/mpl/end.hpp>
 #include <boost/mpl/equal.hpp>
 #include <boost/mpl/range_c.hpp>
 #include <boost/mpl/joint_view.hpp>
 #include <boost/mpl/iterator_range.hpp>

 namespace mpl = boost::mpl;

 template<typename Seq, typename Iter>
 struct rotate_view
     : mpl::joint_view<
           mpl::iterator_range<Iter, typename mpl::end<Seq>::type>,
           mpl::iterator_range<typename mpl::begin<Seq>::type, Iter>
       >
 {
 };

 int main()
 {
     typedef mpl::vector_c<int, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4> v;
     typedef rotate_view<v, mpl::advance_c<mpl::begin<v>::type, 5>::type> view;
     BOOST_STATIC_ASSERT((mpl::equal<view, mpl::range_c<int, 0, 10> >::value));
 }

BOOST WIKI | RecentChanges | Preferences | Page List | Links List
Edit text of this page | View other revisions
Last edited March 27, 2005 12:16 pm (diff)
Search:
Disclaimer: This site not officially maintained by Boost Developers