vector_c.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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/vector_c.hpp>
  12. #include <boost/mpl/front.hpp>
  13. #include <boost/mpl/size.hpp>
  14. #include <boost/mpl/aux_/test.hpp>
  15. #if !BOOST_WORKAROUND(BOOST_MSVC, <=1200)
  16. MPL_TEST_CASE()
  17. {
  18. typedef vector_c<bool,true>::type v1;
  19. typedef vector_c<bool,false>::type v2;
  20. MPL_ASSERT(( is_same< v1::value_type, bool > ));
  21. MPL_ASSERT(( is_same< v2::value_type, bool > ));
  22. MPL_ASSERT_RELATION( front<v1>::type::value, ==, true );
  23. MPL_ASSERT_RELATION( front<v2>::type::value, ==, false );
  24. }
  25. #endif
  26. MPL_TEST_CASE()
  27. {
  28. typedef vector_c<int,-1> v1;
  29. typedef vector_c<int,0,1> v2;
  30. typedef vector_c<int,1,2,3> v3;
  31. MPL_ASSERT(( is_same< v1::value_type, int > ));
  32. MPL_ASSERT(( is_same< v2::value_type, int > ));
  33. MPL_ASSERT(( is_same< v3::value_type, int > ));
  34. MPL_ASSERT_RELATION( size<v1>::value, ==, 1 );
  35. MPL_ASSERT_RELATION( size<v2>::value, ==, 2 );
  36. MPL_ASSERT_RELATION( size<v3>::value, ==, 3 );
  37. MPL_ASSERT_RELATION( front<v1>::type::value, ==, -1 );
  38. MPL_ASSERT_RELATION( front<v2>::type::value, ==, 0 );
  39. MPL_ASSERT_RELATION( front<v3>::type::value, ==, 1 );
  40. }
  41. MPL_TEST_CASE()
  42. {
  43. typedef vector_c<unsigned,0> v1;
  44. typedef vector_c<unsigned,1,2> v2;
  45. MPL_ASSERT(( is_same< v1::value_type, unsigned > ));
  46. MPL_ASSERT(( is_same< v2::value_type, unsigned > ));
  47. MPL_ASSERT_RELATION( size<v1>::type::value, ==, 1 );
  48. MPL_ASSERT_RELATION( size<v2>::type::value, ==, 2 );
  49. MPL_ASSERT_RELATION( front<v1>::type::value, ==, 0 );
  50. MPL_ASSERT_RELATION( front<v2>::type::value, ==, 1 );
  51. }