1
2 // Copyright Aleksey Gurtovoy 2001-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/logical.hpp>
15 #include <boost/mpl/comparison.hpp>
16 #include <boost/mpl/lambda.hpp>
17 #include <boost/mpl/size_t.hpp>
18 #include <boost/mpl/int.hpp>
19 #include <boost/mpl/bool.hpp>
20 #include <boost/mpl/sizeof.hpp>
21 #include <boost/mpl/apply.hpp>
22
23 #include <boost/mpl/aux_/test.hpp>
24
25 #include <boost/type_traits/is_same.hpp>
26 #include <boost/type_traits/is_float.hpp>
27
28 struct my
29 {
30 char a[100];
31 };
32
MPL_TEST_CASE()33 MPL_TEST_CASE()
34 {
35 // !(x == char) && !(x == double) || sizeof(x) > 8
36 typedef lambda<
37 or_<
38 and_<
39 not_< boost::is_same<_1, char> >
40 , not_< boost::is_float<_1> >
41 >
42 , greater< sizeof_<_1>, mpl::size_t<8> >
43 >
44 >::type f;
45
46 MPL_ASSERT_NOT(( apply_wrap1<f,char> ));
47 MPL_ASSERT_NOT(( apply_wrap1<f,double> ));
48 MPL_ASSERT(( apply_wrap1<f,long> ));
49 MPL_ASSERT(( apply_wrap1<f,my> ));
50 }
51
MPL_TEST_CASE()52 MPL_TEST_CASE()
53 {
54 // x == y || x == my || sizeof(x) == sizeof(y)
55 typedef lambda<
56 or_<
57 boost::is_same<_1, _2>
58 , boost::is_same<_2, my>
59 , equal_to< sizeof_<_1>, sizeof_<_2> >
60 >
61 >::type f;
62
63 MPL_ASSERT_NOT(( apply_wrap2<f,double,char> ));
64 MPL_ASSERT_NOT(( apply_wrap2<f,my,int> ));
65 MPL_ASSERT_NOT(( apply_wrap2<f,my,char[99]> ));
66 MPL_ASSERT(( apply_wrap2<f,int,int> ));
67 MPL_ASSERT(( apply_wrap2<f,my,my> ));
68 MPL_ASSERT(( apply_wrap2<f,signed long, unsigned long> ));
69 }
70
MPL_TEST_CASE()71 MPL_TEST_CASE()
72 {
73 // bind <-> lambda interaction
74 typedef lambda< less<_1,_2> >::type pred;
75 typedef bind2< pred, _1, int_<4> > f;
76
77 MPL_ASSERT(( apply_wrap1< f,int_<3> > ));
78 }
79