joint_view.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright Aleksey Gurtovoy 2001-2004
  2. //
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // See http://www.boost.org/libs/mpl for documentation.
  8. // $Id$
  9. // $Date$
  10. // $Revision$
  11. #include <boost/mpl/joint_view.hpp>
  12. #include <boost/mpl/range_c.hpp>
  13. #include <boost/mpl/list.hpp>
  14. #include <boost/mpl/equal.hpp>
  15. #include <boost/mpl/size.hpp>
  16. #include <boost/mpl/aux_/test.hpp>
  17. MPL_TEST_CASE()
  18. {
  19. typedef joint_view<
  20. range_c<int,0,10>
  21. , range_c<int,10,15>
  22. > numbers;
  23. typedef range_c<int,0,15> answer;
  24. MPL_ASSERT(( equal<numbers,answer> ));
  25. MPL_ASSERT(( equal<numbers::type,answer> ));
  26. MPL_ASSERT_RELATION( size<numbers>::value, ==, 15 );
  27. }
  28. template< typename View > struct test_is_empty
  29. {
  30. typedef typename begin<View>::type first_;
  31. typedef typename end<View>::type last_;
  32. MPL_ASSERT_RELATION( size<View>::value, ==, 0 );
  33. MPL_ASSERT(( is_same< first_,last_> ));
  34. MPL_ASSERT_INSTANTIATION( View );
  35. MPL_ASSERT_INSTANTIATION( first_ );
  36. MPL_ASSERT_INSTANTIATION( last_ );
  37. };
  38. MPL_TEST_CASE()
  39. {
  40. test_is_empty< joint_view< list0<>,list0<> > >();
  41. test_is_empty< joint_view< list<>,list0<> > >();
  42. test_is_empty< joint_view< list<>,list<> > >();
  43. test_is_empty< joint_view< list<>, joint_view< list0<>,list0<> > > >();
  44. }