test_mpl_ops.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* Boost.MultiIndex test for MPL operations.
  2. *
  3. * Copyright 2003-2008 Joaquin M Lopez Munoz.
  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/multi_index for library home page.
  9. */
  10. #include "test_mpl_ops.hpp"
  11. #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
  12. #include "pre_multi_index.hpp"
  13. #include <boost/multi_index_container.hpp>
  14. #include <boost/multi_index/identity.hpp>
  15. #include <boost/multi_index/ordered_index.hpp>
  16. #include <boost/multi_index/sequenced_index.hpp>
  17. #include <boost/mpl/at.hpp>
  18. #include <boost/mpl/list.hpp>
  19. using namespace boost::multi_index;
  20. void test_mpl_ops()
  21. {
  22. typedef multi_index_container<
  23. int,
  24. indexed_by<
  25. ordered_unique<identity<int> >,
  26. ordered_non_unique<identity<int> >
  27. >
  28. > indexed_t1;
  29. BOOST_STATIC_ASSERT((boost::is_same<
  30. boost::mpl::at_c<indexed_t1::index_specifier_type_list,0>::type,
  31. ordered_unique<identity<int> > >::value));
  32. BOOST_STATIC_ASSERT((boost::is_same<
  33. boost::mpl::at_c<indexed_t1::index_specifier_type_list,1>::type,
  34. ordered_non_unique<identity<int> > >::value));
  35. typedef boost::mpl::push_front<
  36. indexed_t1::index_specifier_type_list,
  37. sequenced<>
  38. >::type index_list_t;
  39. typedef multi_index_container<
  40. int,
  41. index_list_t
  42. > indexed_t2;
  43. BOOST_STATIC_ASSERT((boost::is_same<
  44. boost::mpl::at_c<indexed_t2::index_specifier_type_list,0>::type,
  45. sequenced<> >::value));
  46. BOOST_STATIC_ASSERT((boost::is_same<
  47. boost::mpl::at_c<indexed_t2::index_specifier_type_list,1>::type,
  48. boost::mpl::at_c<indexed_t1::index_specifier_type_list,0>::type>::value));
  49. BOOST_STATIC_ASSERT((boost::is_same<
  50. boost::mpl::at_c<indexed_t2::index_specifier_type_list,2>::type,
  51. boost::mpl::at_c<indexed_t1::index_specifier_type_list,1>::type>::value));
  52. typedef multi_index_container<
  53. int,
  54. boost::mpl::list<
  55. ordered_unique<identity<int> >,
  56. ordered_non_unique<identity<int> >
  57. >
  58. > indexed_t3;
  59. BOOST_STATIC_ASSERT((boost::is_same<
  60. boost::mpl::at_c<indexed_t3::index_specifier_type_list,0>::type,
  61. boost::mpl::at_c<indexed_t1::index_specifier_type_list,0>::type>::value));
  62. BOOST_STATIC_ASSERT((boost::is_same<
  63. boost::mpl::at_c<indexed_t3::index_specifier_type_list,1>::type,
  64. boost::mpl::at_c<indexed_t1::index_specifier_type_list,1>::type>::value));
  65. }