zip_view_ignore.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*=============================================================================
  2. Copyright (c) 2001-2007 Joel de Guzman
  3. Copyright (c) 2007 Dan Marsden
  4. Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. ==============================================================================*/
  7. #include <boost/detail/lightweight_test.hpp>
  8. #include <boost/fusion/container/vector.hpp>
  9. #include <boost/fusion/view/zip_view.hpp>
  10. #include <boost/fusion/support/unused.hpp>
  11. #include <boost/fusion/iterator.hpp>
  12. #include <boost/fusion/sequence/intrinsic.hpp>
  13. #include <boost/mpl/assert.hpp>
  14. #include <boost/type_traits/is_same.hpp>
  15. int main()
  16. {
  17. using namespace boost::fusion;
  18. {
  19. typedef vector2<int,int> int_vector;
  20. typedef vector2<char,char> char_vector;
  21. typedef vector<int_vector&, unused_type const&, char_vector&> seqs_type;
  22. typedef zip_view<seqs_type> view;
  23. int_vector iv(1,2);
  24. char_vector cv('a','b');
  25. seqs_type seq(iv, unused, cv);
  26. view v(seq);
  27. BOOST_TEST(at_c<0>(front(v)) == 1);
  28. BOOST_TEST(at_c<2>(front(v)) == 'a');
  29. BOOST_TEST(at_c<0>(back(v)) == 2);
  30. BOOST_TEST(at_c<2>(back(v)) == 'b');
  31. typedef boost::fusion::result_of::begin<view>::type first_iterator;
  32. typedef boost::fusion::result_of::value_of<first_iterator>::type first_element;
  33. typedef boost::fusion::result_of::at_c<first_element, 0>::type e0;
  34. typedef boost::fusion::result_of::at_c<first_element, 2>::type e2;
  35. BOOST_MPL_ASSERT((boost::is_same<e0, int&>));
  36. BOOST_MPL_ASSERT((boost::is_same<e2, char&>));
  37. BOOST_TEST(size(front(v)) == 3);
  38. typedef boost::fusion::result_of::value_at_c<view, 0>::type first_value_at;
  39. typedef boost::fusion::result_of::value_at_c<first_value_at, 0>::type v0;
  40. typedef boost::fusion::result_of::value_at_c<first_value_at, 2>::type v2;
  41. BOOST_MPL_ASSERT((boost::is_same<v0, int>));
  42. BOOST_MPL_ASSERT((boost::is_same<v2, char>));
  43. BOOST_TEST(at_c<0>(at_c<0>(v)) == 1);
  44. BOOST_TEST(at_c<2>(at_c<0>(v)) == 'a');
  45. }
  46. return boost::report_errors();
  47. }