]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/type_erasure/test/test_limits.cpp
1 // Boost.TypeErasure library
3 // Copyright 2011 Steven Watanabe
5 // Distributed under the Boost Software License Version 1.0. (See
6 // accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
11 #include <boost/type_erasure/any.hpp>
12 #include <boost/type_erasure/free.hpp>
13 #include <boost/type_erasure/builtin.hpp>
14 #include <boost/mpl/vector.hpp>
15 #include <boost/mpl/transform.hpp>
16 #include <boost/mpl/back_inserter.hpp>
17 #include <boost/mpl/range_c.hpp>
19 #define BOOST_TEST_MAIN
20 #include <boost/test/unit_test.hpp>
22 using namespace boost::type_erasure
;
23 namespace mpl
= boost::mpl
;
31 int func() { return 0; }
33 template<int N
, class... T
>
34 int func(tester
<N
> t0
, T
... t
)
36 return t0
.value
+ func(t
...);
39 BOOST_TYPE_ERASURE_FREE((has_func
), func
)
41 template<class T
= _self
>
42 struct common
: mpl::vector
<
46 BOOST_AUTO_TEST_CASE(test_arity
)
49 any
<mpl::vector
<common
<>, has_func
<int(_self
, _self
, _self
, _self
, _self
, _self
)> > > x(t
);
50 int i
= func(x
, x
, x
, x
, x
, x
);
54 BOOST_AUTO_TEST_CASE(test_null_arity
)
56 any
<mpl::vector
<common
<>, has_func
<int(_self
, _self
, _self
, _self
, _self
, _self
)>, relaxed
> > x
;
57 BOOST_CHECK_THROW(func(x
, x
, x
, x
, x
, x
), boost::type_erasure::bad_function_call
);
60 template<class T0
, class... T
>
63 static int apply(T0 t0
) { return func(t0
); }
66 BOOST_AUTO_TEST_CASE(test_template_arity
)
68 typedef my_concept
<_self
, int, int, int, int, int, int> concept1
;
70 any
<mpl::vector
<common
<>, concept1
> > x(t
);
71 int i
= call(concept1(), x
);
78 typedef has_func
<int(_self
, tester
<T::value
>)> type
;
81 BOOST_AUTO_TEST_CASE(test_vtable_size
)
86 mpl::transform
<mpl::range_c
<int, 1, 60>,
88 mpl::back_inserter
< boost::mp11::mp_list
<> >