]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/parameter/test/basics.cpp
1 // Copyright David Abrahams, Daniel Wallin 2003. Use, modification and
2 // distribution is subject to the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
6 #include <boost/parameter.hpp>
9 #include <boost/bind.hpp>
10 #include <boost/ref.hpp>
16 // A separate function for getting the "value" key, so we can deduce
17 // F and use lazy_binding on it.
18 template <class Params
, class F
>
19 typename
boost::parameter::lazy_binding
<Params
,tag::value
,F
>::type
20 extract_value(Params
const& p
, F
const& f
)
22 typename
boost::parameter::lazy_binding
<
24 >::type v
= p
[value
|| f
];
28 template<class Params
>
29 int f_impl(Params
const& p
)
31 typename
boost::parameter::binding
<Params
, tag::name
>::type
34 typename
boost::parameter::binding
<
35 Params
, tag::value
, double
36 >::type v
= extract_value(p
, boost::bind(&value_default
));
38 typename
boost::parameter::binding
<
39 Params
, tag::index
, int
41 #if BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042))
52 template<class Tester
, class Name
, class Value
, class Index
>
53 int f(Tester
const& t
, const Name
& name_
,
54 const Value
& value_
, const Index
& index_
)
56 return f_impl(f_parameters()(t
, name_
, value_
, index_
));
59 template<class Tester
, class Name
, class Value
>
60 int f(Tester
const& t
, const Name
& name_
, const Value
& value_
)
62 return f_impl(f_parameters()(t
, name_
, value_
));
65 template<class Tester
, class Name
>
66 int f(Tester
const& t
, const Name
& name_
)
68 return f_impl(f_parameters()(t
, name_
));
71 template<class Params
>
72 int f_list(Params
const& params
)
74 return f_impl(params
);
89 test::values(S("foo"), S("bar"), S("baz"))
90 , S("foo"), S("bar"), S("baz")
95 test::values("foo", 666.222, 56)
96 , index
= boost::ref(x
), name
= "foo"
99 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
100 // No comma operator available on Borland
102 tester
= test::values("foo", 666.222, 56)
103 , index
= boost::ref(x
)
108 //f(index = 56, name = 55); // won't compile
110 return boost::report_errors();