]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/fusion/test/functional/fused_function_object.cpp
1 /*=============================================================================
2 Copyright (c) 2006-2007 Tobias Schwinger
4 Use modification and distribution are subject to the Boost Software
5 License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 http://www.boost.org/LICENSE_1_0.txt).
7 ==============================================================================*/
9 #include <boost/fusion/functional/adapter/fused_function_object.hpp>
10 #include <boost/detail/lightweight_test.hpp>
12 #include <boost/noncopyable.hpp>
13 #include <boost/mpl/empty_base.hpp>
15 #include <boost/fusion/container/generation/make_vector.hpp>
16 #include <boost/fusion/container/vector.hpp>
18 namespace fusion
= boost::fusion
;
19 using boost::noncopyable
;
21 template <class Base
= boost::mpl::empty_base
>
28 template<class Self
, typename T0
, typename T1
>
29 struct result
< Self(T0
, T1
) >
34 template <typename T0
, typename T1
>
35 int operator()(T0
const & x
, T1
const & y
) const
40 template <typename T0
, typename T1
>
41 int operator()(T0
const & x
, T1
const & y
)
46 template <typename T0
, typename T1
>
47 int operator()(T0
& x
, T1
& y
) const
52 template <typename T0
, typename T1
>
53 int operator()(T0
& x
, T1
& y
)
61 test_func
<noncopyable
> f
;
62 fusion::fused_function_object
< test_func
<> > fused_func
;
63 fusion::fused_function_object
< test_func
<noncopyable
> & > fused_func_ref(f
);
64 fusion::fused_function_object
< test_func
<> const > fused_func_c
;
65 fusion::fused_function_object
< test_func
<> > const fused_func_c2
;
66 fusion::fused_function_object
< test_func
<noncopyable
> const & > fused_func_c_ref(f
);
68 fusion::vector
<int,char> lv_vec(1,'\004');
69 BOOST_TEST(fused_func(lv_vec
) == 1);
70 BOOST_TEST(fused_func_c(lv_vec
) == 0);
71 BOOST_TEST(fused_func_c2(lv_vec
) == 0);
72 BOOST_TEST(fused_func_ref(lv_vec
) == 1);
73 BOOST_TEST(fused_func_c_ref(lv_vec
) == 0);
75 BOOST_TEST(fused_func(fusion::make_vector(2,'\003')) == 1);
76 BOOST_TEST(fused_func_c(fusion::make_vector(2,'\003')) == 0);
77 BOOST_TEST(fused_func_c2(fusion::make_vector(2,'\003')) == 0);
78 BOOST_TEST(fused_func_ref(fusion::make_vector(2,'\003')) == 1);
79 BOOST_TEST(fused_func_c_ref(fusion::make_vector(2,'\003')) == 0);
81 return boost::report_errors();