1 
2 // Copyright Aleksey Gurtovoy 2000-2004
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 // $Id$
11 // $Date$
12 // $Revision$
13 
14 #include <boost/mpl/fold.hpp>
15 #include <boost/mpl/reverse_fold.hpp>
16 //#include <boost/mpl/vector.hpp>
17 #include <boost/mpl/list.hpp>
18 #include <boost/mpl/list_c.hpp>
19 #include <boost/mpl/equal.hpp>
20 #include <boost/mpl/equal_to.hpp>
21 #include <boost/mpl/next.hpp>
22 #include <boost/mpl/push_front.hpp>
23 #include <boost/mpl/if.hpp>
24 #include <boost/mpl/less.hpp>
25 #include <boost/mpl/int.hpp>
26 #include <boost/mpl/at.hpp>
27 #include <boost/mpl/size.hpp>
28 #include <boost/type_traits/is_float.hpp>
29 
30 #include <boost/mpl/aux_/test.hpp>
31 
MPL_TEST_CASE()32 MPL_TEST_CASE()
33 {
34     typedef list<long,float,short,double,float,long,long double> types;
35     typedef fold<
36           types
37         , int_<0>
38         , if_< boost::is_float<_2>,next<_1>,_1 >
39         >::type number_of_floats;
40 
41     MPL_ASSERT_RELATION( number_of_floats::value, ==, 4 );
42 }
43 
MPL_TEST_CASE()44 MPL_TEST_CASE()
45 {
46     typedef list_c<int,5,-1,0,-7,-2,0,-5,4> numbers;
47     typedef list_c<int,-1,-7,-2,-5> negatives;
48     typedef reverse_fold<
49           numbers
50         , list_c<int>
51         , if_< less< _2,int_<0> >, push_front<_1,_2>, _1 >
52         >::type result;
53 
54     MPL_ASSERT(( equal< result,negatives,equal_to<_1,_2> > ));
55 }
56