index_of.cpp 947 B

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright Eric Friedman 2003
  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/index_of.hpp>
  12. #include <boost/mpl/list.hpp>
  13. #include <boost/mpl/void.hpp>
  14. #include <boost/mpl/aux_/test.hpp>
  15. MPL_TEST_CASE()
  16. {
  17. typedef list< int, double, float >::type types;
  18. typedef index_of< types, int >::type index_of_int;
  19. typedef index_of< types, double >::type index_of_double;
  20. typedef index_of< types, float >::type index_of_float;
  21. typedef index_of< types, char >::type index_of_char;
  22. MPL_ASSERT_RELATION( index_of_int::value, ==, 0 );
  23. MPL_ASSERT_RELATION( index_of_double::value, ==, 1 );
  24. MPL_ASSERT_RELATION( index_of_float::value, ==, 2 );
  25. MPL_ASSERT(( is_void_< index_of_char > ));
  26. }