push_front.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright Aleksey Gurtovoy 2000-2004
  2. // Copyright Steven Watanabe 2009
  3. //
  4. // Distributed under the Boost Software License, Version 1.0.
  5. // (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. //
  8. // See http://www.boost.org/libs/mpl for documentation.
  9. // $Id$
  10. // $Date$
  11. // $Revision$
  12. #include <boost/mpl/push_front.hpp>
  13. #include <boost/mpl/push_back.hpp>
  14. #include <boost/mpl/list/list10.hpp>
  15. #include <boost/mpl/size.hpp>
  16. #include <boost/mpl/front.hpp>
  17. #include <boost/mpl/aux_/test.hpp>
  18. struct no_push_front_tag {};
  19. struct no_push_front
  20. {
  21. typedef no_push_front_tag tag;
  22. };
  23. MPL_TEST_CASE()
  24. {
  25. typedef push_front<list0<>,long>::type res1;
  26. typedef push_front<list1<long>,int>::type res2;
  27. typedef push_front<list2<int,long>,char>::type res3;
  28. MPL_ASSERT_RELATION( size<res1>::value, ==, 1 );
  29. MPL_ASSERT_RELATION( size<res2>::value, ==, 2 );
  30. MPL_ASSERT_RELATION( size<res3>::value, ==, 3 );
  31. MPL_ASSERT(( is_same< front<res1>::type, long > ));
  32. MPL_ASSERT(( is_same< front<res2>::type, int > ));
  33. MPL_ASSERT(( is_same< front<res3>::type, char > ));
  34. MPL_ASSERT(( has_push_front< list0<> > ));
  35. MPL_ASSERT(( has_push_front< list1<long> > ));
  36. MPL_ASSERT_NOT(( has_push_back< list0<> > ));
  37. MPL_ASSERT_NOT(( has_push_front< no_push_front > ));
  38. }