list.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Copyright Aleksey Gurtovoy 2000-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/list.hpp>
  12. #include <boost/mpl/push_front.hpp>
  13. #include <boost/mpl/pop_front.hpp>
  14. #include <boost/mpl/front.hpp>
  15. #include <boost/mpl/size.hpp>
  16. #include <boost/mpl/empty.hpp>
  17. #include <boost/mpl/aux_/test.hpp>
  18. MPL_TEST_CASE()
  19. {
  20. typedef list0<> l0;
  21. typedef list1<char> l1;
  22. typedef list2<char,long> l2;
  23. typedef list9<char,char,char,char,char,char,char,char,char> l9;
  24. MPL_ASSERT_RELATION(size<l0>::value, ==, 0);
  25. MPL_ASSERT_RELATION(size<l1>::value, ==, 1);
  26. MPL_ASSERT_RELATION(size<l2>::value, ==, 2);
  27. MPL_ASSERT_RELATION(size<l9>::value, ==, 9);
  28. MPL_ASSERT(( empty<l0> ));
  29. MPL_ASSERT_NOT(( empty<l1> ));
  30. MPL_ASSERT_NOT(( empty<l2> ));
  31. MPL_ASSERT_NOT(( empty<l9> ));
  32. MPL_ASSERT(( is_same<front<l1>::type,char> ));
  33. MPL_ASSERT(( is_same<front<l2>::type,char> ));
  34. MPL_ASSERT(( is_same<front<l9>::type,char> ));
  35. }
  36. MPL_TEST_CASE()
  37. {
  38. typedef list2<char,long> l2;
  39. typedef begin<l2>::type i1;
  40. typedef next<i1>::type i2;
  41. typedef next<i2>::type i3;
  42. MPL_ASSERT(( is_same<deref<i1>::type,char> ));
  43. MPL_ASSERT(( is_same<deref<i2>::type,long> ));
  44. MPL_ASSERT(( is_same< i3, end<l2>::type > ));
  45. }
  46. MPL_TEST_CASE()
  47. {
  48. typedef list0<> l0;
  49. typedef push_front<l0,char>::type l1;
  50. MPL_ASSERT(( is_same<front<l1>::type,char> ));
  51. typedef push_front<l1,long>::type l2;
  52. MPL_ASSERT(( is_same<front<l2>::type,long> ));
  53. }