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