find.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  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/find.hpp>
  12. #include <boost/mpl/list.hpp>
  13. #include <boost/mpl/list_c.hpp>
  14. #include <boost/mpl/distance.hpp>
  15. #include <boost/mpl/begin_end.hpp>
  16. #include <boost/mpl/int.hpp>
  17. #include <boost/mpl/aux_/test.hpp>
  18. MPL_TEST_CASE()
  19. {
  20. typedef list<int,char,long,short,char,long,double,long>::type types;
  21. typedef list_c<int,1,0,5,1,7,5,0,5> values;
  22. typedef find<types, short>::type types_iter;
  23. typedef find< values, integral_c<int,7> >::type values_iter;
  24. MPL_ASSERT(( is_same< deref<types_iter>::type, short> ));
  25. MPL_ASSERT_RELATION( deref<values_iter>::type::value, ==, 7 );
  26. typedef begin<types>::type types_first;
  27. typedef begin<values>::type values_first;
  28. MPL_ASSERT_RELATION( (mpl::distance< types_first,types_iter >::value), ==, 3 );
  29. MPL_ASSERT_RELATION( (mpl::distance< values_first,values_iter >::value), ==, 4 );
  30. }