count.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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/count.hpp>
  12. #include <boost/mpl/vector.hpp>
  13. #include <boost/mpl/vector_c.hpp>
  14. #include <boost/mpl/integral_c.hpp>
  15. #include <boost/mpl/aux_/test.hpp>
  16. MPL_TEST_CASE()
  17. {
  18. typedef vector<int,char,long,short,char,long,double,long> types;
  19. MPL_ASSERT_RELATION( (count<types,int>::value), ==, 1 );
  20. MPL_ASSERT_RELATION( (count<types,double>::value), ==, 1 );
  21. MPL_ASSERT_RELATION( (count<types,char>::value), ==, 2 );
  22. MPL_ASSERT_RELATION( (count<types,long>::value), ==, 3 );
  23. MPL_ASSERT_RELATION( (count<types,unsigned>::value), ==, 0 );
  24. }
  25. MPL_TEST_CASE()
  26. {
  27. typedef vector_c<int,1,0,5,1,7,5,0,5> values;
  28. MPL_ASSERT_RELATION( (count< values, integral_c<int,1> >::value), ==, 2 );
  29. MPL_ASSERT_RELATION( (count< values, integral_c<int,0> >::value), ==, 2 );
  30. MPL_ASSERT_RELATION( (count< values, integral_c<int,5> >::value), ==, 3 );
  31. MPL_ASSERT_RELATION( (count< values, integral_c<int,7> >::value), ==, 1 );
  32. MPL_ASSERT_RELATION( (count< values, integral_c<int,8> >::value), ==, 0 );
  33. }