single_view.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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/single_view.hpp>
  12. #include <boost/mpl/advance.hpp>
  13. #include <boost/mpl/size.hpp>
  14. #include <boost/mpl/begin_end.hpp>
  15. #include <boost/mpl/equal.hpp>
  16. #include <boost/mpl/aux_/test.hpp>
  17. MPL_TEST_CASE()
  18. {
  19. typedef single_view<int> view;
  20. typedef begin<view>::type first;
  21. typedef end<view>::type last;
  22. MPL_ASSERT(( is_same< deref<first>::type, int > ));
  23. MPL_ASSERT(( is_same< next<first>::type, last > ));
  24. MPL_ASSERT(( is_same< prior<last>::type, first > ));
  25. MPL_ASSERT(( is_same< mpl::advance<first, int_<0> >::type, first > ));
  26. MPL_ASSERT(( is_same< mpl::advance<first, int_<1> >::type, last > ));
  27. MPL_ASSERT(( is_same< mpl::advance<last, int_<0> >::type, last > ));
  28. MPL_ASSERT(( is_same< mpl::advance<last, int_<-1> >::type, first > ));
  29. MPL_ASSERT_RELATION( (mpl::distance<first,first>::value), ==, 0 );
  30. MPL_ASSERT_RELATION( (mpl::distance<first,last>::value), ==, 1 );
  31. MPL_ASSERT_RELATION( (mpl::distance<last,last>::value), ==, 0 );
  32. MPL_ASSERT_RELATION( size<view>::value, ==, 1 );
  33. MPL_ASSERT(( equal< view, view::type > ));
  34. }