multiset.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // Copyright Aleksey Gurtovoy 2003-2006
  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/multiset/multiset0.hpp>
  12. //#include <boost/mpl/multiset/multiset10.hpp>
  13. #include <boost/mpl/insert.hpp>
  14. #include <boost/mpl/count.hpp>
  15. #include <boost/mpl/aux_/test.hpp>
  16. #include <boost/mpl/assert.hpp>
  17. #include <boost/mpl/size.hpp>
  18. #include <boost/mpl/find.hpp>
  19. #include <boost/config.hpp>
  20. /*
  21. struct test_data1
  22. {
  23. typedef multiset0<> s0;
  24. typedef multiset1<int> s1;
  25. typedef multiset2<int,char&> s2;
  26. typedef multiset3<int,char&,int> s3;
  27. typedef multiset4<int,char&,int,abstract> s4;
  28. };
  29. struct test_data2
  30. {
  31. typedef multiset<> s0;
  32. typedef multiset<int> s1;
  33. typedef multiset<int,char&> s2;
  34. typedef multiset<int,char&,int> s3;
  35. typedef multiset<int,char&,int,abstract> s4;
  36. };
  37. */
  38. template< typename S0 >
  39. struct test_data
  40. {
  41. typedef S0 s0;
  42. typedef typename insert<s0,int>::type s1;
  43. typedef typename insert<s1,char&>::type s2;
  44. typedef typename insert<s2,int>::type s3;
  45. typedef typename insert<s3,abstract>::type s4;
  46. };
  47. template< typename T >
  48. void count_test()
  49. {
  50. MPL_ASSERT_RELATION( ( count<BOOST_DEDUCED_TYPENAME T::s0,int>::value ), ==, 0 );
  51. MPL_ASSERT_RELATION( ( count<BOOST_DEDUCED_TYPENAME T::s1,int>::value ), ==, 1 );
  52. MPL_ASSERT_RELATION( ( count<BOOST_DEDUCED_TYPENAME T::s2,int>::value ), ==, 1 );
  53. MPL_ASSERT_RELATION( ( count<BOOST_DEDUCED_TYPENAME T::s2,char&>::value ), ==, 1 );
  54. MPL_ASSERT_RELATION( ( count<BOOST_DEDUCED_TYPENAME T::s3,int>::value ), ==, 2 );
  55. MPL_ASSERT_RELATION( ( count<BOOST_DEDUCED_TYPENAME T::s3,char&>::value ), ==, 1 );
  56. MPL_ASSERT_RELATION( ( count<BOOST_DEDUCED_TYPENAME T::s4,abstract>::value ), ==, 1 );
  57. }
  58. MPL_TEST_CASE()
  59. {
  60. //count_test<test_data1>();
  61. //count_test<test_data2>();
  62. //count_test< test_data< multiset<> > >();
  63. count_test< test_data< multiset0<> > >();
  64. }
  65. /*
  66. // Use a template for testing so that GCC will show us the actual types involved
  67. template <class S>
  68. void find_test()
  69. {
  70. BOOST_MPL_ASSERT_RELATION( size<S>::value, ==, 3 );
  71. typedef typename end<S>::type not_found;
  72. BOOST_MPL_ASSERT_NOT(( is_same<BOOST_DEDUCED_TYPENAME find<S,int>::type,not_found> ));
  73. BOOST_MPL_ASSERT_NOT(( is_same<BOOST_DEDUCED_TYPENAME find<S,long>::type,not_found> ));
  74. BOOST_MPL_ASSERT_NOT(( is_same<BOOST_DEDUCED_TYPENAME find<S,char>::type,not_found> ));
  75. BOOST_MPL_ASSERT(( is_same<BOOST_DEDUCED_TYPENAME find<S,char*>::type,not_found> ));
  76. }
  77. */
  78. MPL_TEST_CASE()
  79. {
  80. // agurt 11/jun/06: multiset does not implement iterators yet!
  81. // typedef insert<multiset0<>, int>::type set_of_1_int;
  82. // typedef begin<set_of_1_int>::type iter_to_1_int;
  83. // BOOST_MPL_ASSERT(( is_same< deref<iter_to_1_int>::type, int > ));
  84. typedef multiset0<> s0;
  85. typedef insert<s0,int>::type s1;
  86. typedef insert<s1,long>::type s2;
  87. typedef insert<s2,char>::type myset;
  88. // find_test<myset>();
  89. // find_test<myset::type>();
  90. }