]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/mpl/test/apply.cpp
2 // Copyright Aleksey Gurtovoy 2000-2004
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)
8 // See http://www.boost.org/libs/mpl for documentation.
14 #include <boost/mpl/apply.hpp>
15 #include <boost/mpl/lambda.hpp>
16 #include <boost/mpl/plus.hpp>
17 #include <boost/mpl/int.hpp>
18 #include <boost/mpl/aux_/test.hpp>
21 template< typename T
> struct std_vector
23 #if defined(BOOST_MPL_CFG_NO_IMPLICIT_METAFUNCTIONS)
24 typedef std_vector type
;
25 BOOST_MPL_AUX_LAMBDA_SUPPORT(1, std_vector
, (T
))
32 typedef plus
<int_
<2>,int_
<3> > plus1
;
33 typedef lambda
<plus1
>::type plus2
;
34 MPL_ASSERT(( is_same
< plus1
,plus2
> ));
36 typedef lambda
<std_vector
<int> >::type v
;
37 MPL_ASSERT(( is_same
< v
,std_vector
<int> > ));
39 typedef lambda
<std_vector
<_1
> >::type make_vector
;
40 typedef apply_wrap1
<make_vector
,int>::type v_int
;
41 MPL_ASSERT(( is_same
< v_int
,std_vector
<int> > ));
46 typedef plus
<_1
,_2
> plus_fun
;
47 typedef apply2
<plus_fun
,int_
<2>,int_
<3> >::type res
;
49 MPL_ASSERT_RELATION( res::value
, ==, 5 );
54 typedef apply1
<_1
, plus
<_1
,_2
> >::type plus_fun
;
55 MPL_ASSERT(( is_same
< plus_fun
,plus
<_1
,_2
> > ));
57 typedef apply2
<plus_fun
,int_
<2>,int_
<3> >::type res
;
58 MPL_ASSERT_RELATION( res::value
, ==, 5 );
63 typedef lambda
< lambda
<_1
> >::type make_lambda
;
64 typedef apply_wrap1
< make_lambda
,std_vector
<int> >::type v
;
65 MPL_ASSERT(( is_same
< v
,std_vector
<int> > ));
67 typedef apply_wrap1
< make_lambda
,std_vector
<_1
> >::type make_vector
;
68 typedef apply_wrap1
< make_vector
,int >::type v_int
;
69 MPL_ASSERT(( is_same
< v_int
,std_vector
<int> > ));
74 typedef apply1
< _1
, std_vector
<int> >::type v
;
75 MPL_ASSERT(( is_same
< v
,std_vector
<int> > ));
77 typedef apply1
< _1
, std_vector
<_1
> >::type v_lambda
;
78 typedef apply1
<v_lambda
,int>::type v_int
;
79 MPL_ASSERT(( is_same
< v_int
,std_vector
<int> > ));
84 typedef apply1
< lambda
<_1
>, std_vector
<int> >::type v
;
85 MPL_ASSERT(( is_same
< v
,std_vector
<int> > ));
87 typedef apply1
< lambda
<_1
>, std_vector
<_1
> >::type make_vector
;
88 typedef apply_wrap1
< make_vector
,int >::type v_int
;
89 MPL_ASSERT(( is_same
< v_int
,std_vector
<int> > ));
94 typedef apply1
< lambda
<_1
>, plus
<_1
,_2
> >::type plus_fun
;
95 typedef apply_wrap2
< plus_fun
,int_
<2>,int_
<3> >::type res
;
97 MPL_ASSERT_RELATION( res::value
, ==, 5 );
102 typedef bind2
<plus
<>,_1
,_1
> b1
;
103 typedef lambda
<b1
>::type b2
;
104 MPL_ASSERT(( is_same
< b1
,b2
> ));
109 #if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
110 typedef lambda
< lambda
< bind2
<plus
<>,_1
,_1
> > >::type make_lambda
;
111 typedef apply_wrap1
< make_lambda::type
, int_
<5> >::type res
;
112 MPL_ASSERT_RELATION( res::value
, ==, 10 );
118 typedef apply1
< bind2
<plus
<>,_1
,_1
>, int_
<5> >::type res
;
119 MPL_ASSERT_RELATION( res::value
, ==, 10 );
124 typedef apply1
<_1
, lambda
<plus
<_1
,_2
> > >::type plus_fun
;
125 typedef apply_wrap2
< plus_fun::type
, int_
<2>,int_
<3> >::type res
;
127 MPL_ASSERT_RELATION( res::value
, ==, 5 );