]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/parameter/test/literate/building-argumentpacks0.cpp
2 #include <boost/parameter.hpp>
5 BOOST_PARAMETER_NAME(index
)
7 template <typename ArgumentPack
>
8 int print_index(ArgumentPack
const& args
)
10 std::cout
<< "index = " << args
[_index
] << std::endl
;
14 BOOST_PARAMETER_NAME(name
)
16 template <typename ArgumentPack
>
17 int print_name_and_index(ArgumentPack
const& args
)
19 std::cout
<< "name = " << args
[_name
] << "; ";
20 return print_index(args
);
23 #include <boost/core/lightweight_test.hpp>
24 #include <boost/mpl/bool.hpp>
25 #include <boost/mpl/placeholders.hpp>
26 #include <boost/mpl/if.hpp>
27 #include <boost/type_traits/is_convertible.hpp>
31 int x
= print_index(_index
= 3); // prints "index = 3"
32 int y
= print_name_and_index((_index
= 3, _name
= "jones"));
33 boost::parameter::parameters
<
34 boost::parameter::required
<
37 boost::is_convertible
<boost::mpl::_
,char const*>
42 , boost::parameter::optional
<
45 boost::is_convertible
<boost::mpl::_
,int>
51 char const sam
[] = "sam";
53 int z0
= print_name_and_index(spec(sam
, twelve
));
54 int z1
= print_name_and_index(spec(_index
=12, _name
="sam"));
59 return boost::report_errors();